Skip to content

Commit

Permalink
fix: direct address busy loop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Nov 28, 2018
1 parent f6b611c commit 0ebb884
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type GRPCClient struct {
creator ClientCreator
opts *clientOptions
clients map[string]interface{}
conns map[string]*grpc.ClientConn
}

// NewGRPCClient returns a GRPC Client
Expand All @@ -33,6 +34,19 @@ func NewGRPCClient(creator ClientCreator, opts ...ClientOption) *GRPCClient {
}
}

// Close close
func (c *GRPCClient) Close() error {
c.RLock()
defer c.RUnlock()

var err error
for _, conn := range c.conns {
err = conn.Close()
}

return err
}

// GetServiceClient returns a grpc client
func (c *GRPCClient) GetServiceClient(name string) (interface{}, error) {
c.RLock()
Expand Down
1 change: 1 addition & 0 deletions direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ func (lr *localResolver) firstNext() ([]*naming.Update, error) {
Addr: addr,
})
}
lr.firstCalled = true
return values, nil
}

0 comments on commit 0ebb884

Please sign in to comment.