zouyx commented on a change in pull request #1045:
URL: https://github.com/apache/dubbo-go/pull/1045#discussion_r571518970



##########
File path: protocol/dubbo/dubbo_invoker.go
##########
@@ -162,27 +181,38 @@ func (di *DubboInvoker) getTimeout(invocation 
*invocation_impl.RPCInvocation) ti
 }
 
 func (di *DubboInvoker) IsAvailable() bool {
-       return di.client.IsAvailable()
+       client := di.getClient()
+       if client != nil {
+               return client.IsAvailable()
+       }
+
+       return false
 }
 
 // Destroy destroy dubbo client invoker.
 func (di *DubboInvoker) Destroy() {
        di.quitOnce.Do(func() {
+               di.BaseInvoker.Stop()
+               var times int64
                for {
-                       if di.reqNum == 0 {
-                               di.reqNum = -1
-                               logger.Infof("dubboInvoker is 
destroyed,url:{%s}", di.GetUrl().Key())
+                       times = di.BaseInvoker.InvokeTimes()
+                       if times == 0 {

Review comment:
       判断标准应该是 client 还是 times ?
   我觉得还是像以前一样都兼顾一下比较好

##########
File path: protocol/dubbo/dubbo_invoker.go
##########
@@ -123,18 +138,22 @@ func (di *DubboInvoker) Invoke(ctx context.Context, 
invocation protocol.Invocati
        //response := NewResponse(inv.Reply(), nil)
        rest := &protocol.RPCResult{}
        timeout := di.getTimeout(inv)
-       if async {
-               if callBack, ok := inv.CallBack().(func(response 
common.CallbackResponse)); ok {
-                       //result.Err = 
di.client.AsyncCall(NewRequest(url.Location, url, inv.MethodName(), 
inv.Arguments(), inv.Attachments()), callBack, response)
-                       result.Err = di.client.AsyncRequest(&invocation, url, 
timeout, callBack, rest)
-               } else {
-                       result.Err = di.client.Send(&invocation, url, timeout)
-               }
+       client := di.getClient()

Review comment:
       di.BaseInvoker.IsAvailable() 时,同时返回 client 是否可以减少一次再加锁的机会?

##########
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 {

Review comment:
       同上




----------------------------------------------------------------
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]

Reply via email to