diff --git a/client.go b/client.go index c94a915..25e3880 100644 --- a/client.go +++ b/client.go @@ -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 @@ -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() diff --git a/direct.go b/direct.go index 26debab..69190ee 100644 --- a/direct.go +++ b/direct.go @@ -55,5 +55,6 @@ func (lr *localResolver) firstNext() ([]*naming.Update, error) { Addr: addr, }) } + lr.firstCalled = true return values, nil }