AlexStocks commented on a change in pull request #1045:
URL: https://github.com/apache/dubbo-go/pull/1045#discussion_r571737529
##########
File path: protocol/grpc/grpc_invoker.go
##########
@@ -83,21 +127,47 @@ func (gi *GrpcInvoker) Invoke(ctx context.Context,
invocation protocol.Invocatio
// IsAvailable get available status
func (gi *GrpcInvoker) IsAvailable() bool {
- return gi.BaseInvoker.IsAvailable() && gi.client.GetState() !=
connectivity.Shutdown
+ client := gi.getClient()
+ if client != nil {
+ return gi.BaseInvoker.IsAvailable() && client.GetState() !=
connectivity.Shutdown
+ }
+
+ return false
}
// IsDestroyed get destroyed status
func (gi *GrpcInvoker) IsDestroyed() bool {
- return gi.BaseInvoker.IsDestroyed() && gi.client.GetState() ==
connectivity.Shutdown
+ client := gi.getClient()
+ if client != nil {
+ return gi.BaseInvoker.IsDestroyed() && client.GetState() ==
connectivity.Shutdown
+ }
+
+ return false
}
// Destroy will destroy gRPC's invoker and client, so it is only called once
func (gi *GrpcInvoker) Destroy() {
gi.quitOnce.Do(func() {
- gi.BaseInvoker.Destroy()
-
- if gi.client != nil {
- _ = gi.client.Close()
+ gi.BaseInvoker.Stop()
+ var times int64
+ for {
+ times = gi.BaseInvoker.InvokeTimes()
+ if times == 0 {
+ gi.BaseInvoker.AddInvokerTimes(-1)
+ logger.Infof("grpcInvoker is destroyed,
url:{%s}", gi.GetUrl().Key())
+ gi.BaseInvoker.Destroy()
+ client := gi.getClient()
+ if client != nil {
+ client.Close()
+ gi.setClient(nil)
Review comment:
good advice.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]