From f3934e038e4c8b185447cc2c0d60f71e8a3d14b0 Mon Sep 17 00:00:00 2001 From: DeniskaRediska Date: Wed, 23 Oct 2019 15:41:58 +0300 Subject: [PATCH] fix panic --- .version | 2 +- proxy/grpc/client.go | 5 +++++ proxy/http/client.go | 5 +++++ redis/client.go | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.version b/.version index bcab45a..05b19b1 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.0.3 +0.0.4 \ No newline at end of file diff --git a/proxy/grpc/client.go b/proxy/grpc/client.go index 3924ac3..f0a9285 100644 --- a/proxy/grpc/client.go +++ b/proxy/grpc/client.go @@ -31,6 +31,11 @@ func NewProxy() *grpcProxy { } func (p *grpcProxy) ProxyRequest(ctx *fasthttp.RequestCtx) { + if p.client == nil { + log.Error(log_code.ErrorClientGrpc, "client undefined") + return + } + currentTime := time.Now() uri := string(ctx.RequestURI()) diff --git a/proxy/http/client.go b/proxy/http/client.go index dd152b1..f65fd7d 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -30,6 +30,11 @@ func (p *httpProxy) Consumer(addressList []structure.AddressConfiguration) bool } func (p *httpProxy) ProxyRequest(ctx *fasthttp.RequestCtx) { + if p.client == nil { + log.Error(log_code.ErrorClientHttp, "client undefined") + return + } + req := &ctx.Request res := &ctx.Response diff --git a/redis/client.go b/redis/client.go index 712d064..7f89db3 100644 --- a/redis/client.go +++ b/redis/client.go @@ -21,6 +21,10 @@ func (c *redisClient) ReceiveConfiguration(configuration structure.RedisConfigur } func (c *redisClient) GetTokens(appToken string) (map[string]string, error) { + if c.cli == nil { + return nil, errors.New("client undefined") + } + instanceUuid := config.Get().(*conf.Configuration).InstanceUuid key := fmt.Sprintf("%s|%s", appToken, instanceUuid)