From 1ca43cde6ce9a633d47f0b19bb8a3d967b0231b2 Mon Sep 17 00:00:00 2001 From: bandl <1658002533@qq.com> Date: Tue, 2 Nov 2021 13:02:02 +0800 Subject: [PATCH] fix(aof): fix aof is nil --- storage/service/single_service.gen.go | 88 ++++++++++++++++++++------- storage/temp/service.template | 4 +- 2 files changed, 69 insertions(+), 23 deletions(-) diff --git a/storage/service/single_service.gen.go b/storage/service/single_service.gen.go index 33b784c..6247dc2 100644 --- a/storage/service/single_service.gen.go +++ b/storage/service/single_service.gen.go @@ -19,7 +19,9 @@ func (s *singleService) LIndex( if err != nil { return nil, err } - s.aof.SendRequest("LIndex", req) + if s.aof != nil { + s.aof.SendRequest("LIndex", req) + } return resp, nil }) @@ -45,7 +47,9 @@ func (s *singleService) LLen( if err != nil { return nil, err } - s.aof.SendRequest("LLen", req) + if s.aof != nil { + s.aof.SendRequest("LLen", req) + } return resp, nil }) @@ -71,7 +75,9 @@ func (s *singleService) LPop( if err != nil { return nil, err } - s.aof.SendRequest("LPop", req) + if s.aof != nil { + s.aof.SendRequest("LPop", req) + } return resp, nil }) @@ -97,7 +103,9 @@ func (s *singleService) LPush( if err != nil { return nil, err } - s.aof.SendRequest("LPush", req) + if s.aof != nil { + s.aof.SendRequest("LPush", req) + } return resp, nil }) @@ -123,7 +131,9 @@ func (s *singleService) LPushX( if err != nil { return nil, err } - s.aof.SendRequest("LPushX", req) + if s.aof != nil { + s.aof.SendRequest("LPushX", req) + } return resp, nil }) @@ -149,7 +159,9 @@ func (s *singleService) LRange( if err != nil { return nil, err } - s.aof.SendRequest("LRange", req) + if s.aof != nil { + s.aof.SendRequest("LRange", req) + } return resp, nil }) @@ -175,7 +187,9 @@ func (s *singleService) LRem( if err != nil { return nil, err } - s.aof.SendRequest("LRem", req) + if s.aof != nil { + s.aof.SendRequest("LRem", req) + } return resp, nil }) @@ -201,7 +215,9 @@ func (s *singleService) LSet( if err != nil { return nil, err } - s.aof.SendRequest("LSet", req) + if s.aof != nil { + s.aof.SendRequest("LSet", req) + } return resp, nil }) @@ -227,7 +243,9 @@ func (s *singleService) RPop( if err != nil { return nil, err } - s.aof.SendRequest("RPop", req) + if s.aof != nil { + s.aof.SendRequest("RPop", req) + } return resp, nil }) @@ -253,7 +271,9 @@ func (s *singleService) LTrim( if err != nil { return nil, err } - s.aof.SendRequest("LTrim", req) + if s.aof != nil { + s.aof.SendRequest("LTrim", req) + } return resp, nil }) @@ -279,7 +299,9 @@ func (s *singleService) RPush( if err != nil { return nil, err } - s.aof.SendRequest("RPush", req) + if s.aof != nil { + s.aof.SendRequest("RPush", req) + } return resp, nil }) @@ -305,7 +327,9 @@ func (s *singleService) RPushX( if err != nil { return nil, err } - s.aof.SendRequest("RPushX", req) + if s.aof != nil { + s.aof.SendRequest("RPushX", req) + } return resp, nil }) @@ -331,7 +355,9 @@ func (s *singleService) Set( if err != nil { return nil, err } - s.aof.SendRequest("Set", req) + if s.aof != nil { + s.aof.SendRequest("Set", req) + } return resp, nil }) @@ -357,7 +383,9 @@ func (s *singleService) Get( if err != nil { return nil, err } - s.aof.SendRequest("Get", req) + if s.aof != nil { + s.aof.SendRequest("Get", req) + } return resp, nil }) @@ -383,7 +411,9 @@ func (s *singleService) Add( if err != nil { return nil, err } - s.aof.SendRequest("Add", req) + if s.aof != nil { + s.aof.SendRequest("Add", req) + } return resp, nil }) @@ -409,7 +439,9 @@ func (s *singleService) Reduce( if err != nil { return nil, err } - s.aof.SendRequest("Reduce", req) + if s.aof != nil { + s.aof.SendRequest("Reduce", req) + } return resp, nil }) @@ -435,7 +467,9 @@ func (s *singleService) Setnx( if err != nil { return nil, err } - s.aof.SendRequest("Setnx", req) + if s.aof != nil { + s.aof.SendRequest("Setnx", req) + } return resp, nil }) @@ -461,7 +495,9 @@ func (s *singleService) SetBit( if err != nil { return nil, err } - s.aof.SendRequest("SetBit", req) + if s.aof != nil { + s.aof.SendRequest("SetBit", req) + } return resp, nil }) @@ -487,7 +523,9 @@ func (s *singleService) GetBit( if err != nil { return nil, err } - s.aof.SendRequest("GetBit", req) + if s.aof != nil { + s.aof.SendRequest("GetBit", req) + } return resp, nil }) @@ -513,7 +551,9 @@ func (s *singleService) GetRange( if err != nil { return nil, err } - s.aof.SendRequest("GetRange", req) + if s.aof != nil { + s.aof.SendRequest("GetRange", req) + } return resp, nil }) @@ -539,7 +579,9 @@ func (s *singleService) GetSet( if err != nil { return nil, err } - s.aof.SendRequest("GetSet", req) + if s.aof != nil { + s.aof.SendRequest("GetSet", req) + } return resp, nil }) @@ -565,7 +607,9 @@ func (s *singleService) StrLen( if err != nil { return nil, err } - s.aof.SendRequest("StrLen", req) + if s.aof != nil { + s.aof.SendRequest("StrLen", req) + } return resp, nil }) diff --git a/storage/temp/service.template b/storage/temp/service.template index 9d63598..1fd2cec 100644 --- a/storage/temp/service.template +++ b/storage/temp/service.template @@ -20,7 +20,9 @@ func (s *singleService) {{key.method}}( if err != nil{ return nil, err } - s.aof.SendRequest("{{key.method}}", req) + if s.aof != nil { + s.aof.SendRequest("{{key.method}}", req) + } return resp, nil })