Commit 2fc80bb1 authored by ztelur's avatar ztelur

fix linter problem

parent 92bf5baf
...@@ -127,7 +127,6 @@ type Client struct { ...@@ -127,7 +127,6 @@ type Client struct {
// NewClient create a client instance with name, endpoints etc. // NewClient create a client instance with name, endpoints etc.
func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat int) (*Client, error) { func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat int) (*Client, error) {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel()
rawClient, err := clientv3.New(clientv3.Config{ rawClient, err := clientv3.New(clientv3.Config{
Context: ctx, Context: ctx,
...@@ -136,6 +135,7 @@ func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat ...@@ -136,6 +135,7 @@ func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat
DialOptions: []grpc.DialOption{grpc.WithBlock()}, DialOptions: []grpc.DialOption{grpc.WithBlock()},
}) })
if err != nil { if err != nil {
cancel()
return nil, perrors.WithMessage(err, "new raw client block connect to server") return nil, perrors.WithMessage(err, "new raw client block connect to server")
} }
...@@ -153,6 +153,7 @@ func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat ...@@ -153,6 +153,7 @@ func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat
} }
if err := c.maintenanceStatus(); err != nil { if err := c.maintenanceStatus(); err != nil {
cancel()
return nil, perrors.WithMessage(err, "client maintenance status") return nil, perrors.WithMessage(err, "client maintenance status")
} }
return c, nil return c, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment