diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index 4d4cb3653420d8515ce8d6b383e14db27d8b9078..14197f1cd067b77fbb7fdbd47861fec2e0bf2e59 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -96,6 +96,9 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati defer atomic.AddInt64(&(di.reqNum), -1) inv := invocation.(*invocation_impl.RPCInvocation) + // init param + inv.SetAttachments(constant.PATH_KEY, di.GetUrl().Path) + inv.SetAttachments(constant.VERSION_KEY, di.GetUrl().GetParam(constant.VERSION_KEY, "")) for _, k := range attachmentKey { if v := di.GetUrl().GetParam(k, ""); len(v) > 0 { inv.SetAttachments(k, v) diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 09a23bfdd43bf20aa72d6c97c6b638e387956754..4bff575b33ef079d41d76313bdca6b7006ad015b 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -143,10 +143,10 @@ func GetProtocol() protocol.Protocol { } func doHandleRequest(rpcInvocation *invocation.RPCInvocation) protocol.RPCResult { - exporter, _ := dubboProtocol.ExporterMap().Load(rpcInvocation.Invoker().GetUrl().ServiceKey()) + exporter, _ := dubboProtocol.ExporterMap().Load(rpcInvocation.ServiceKey()) result := protocol.RPCResult{} if exporter == nil { - err := fmt.Errorf("don't have this exporter, key: %s", rpcInvocation.Invoker().GetUrl().ServiceKey()) + err := fmt.Errorf("don't have this exporter, key: %s", rpcInvocation.ServiceKey()) logger.Errorf(err.Error()) result.Err = err //reply(session, p, hessian.PackageResponse) @@ -168,7 +168,7 @@ func doHandleRequest(rpcInvocation *invocation.RPCInvocation) protocol.RPCResult //p.Body = hessian.NewResponse(res, nil, result.Attachments()) } } else { - result.Err = fmt.Errorf("don't have the invoker, key: %s", rpcInvocation.Invoker().GetUrl().ServiceKey()) + result.Err = fmt.Errorf("don't have the invoker, key: %s", rpcInvocation.ServiceKey()) } return result } diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index b207fd0b0cc4eb7de8409a8c46c6fc9ef0baa5c7..2494c39da2a4d88cd90e778429d75a5a243b4f39 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -18,11 +18,13 @@ package invocation import ( + "bytes" "reflect" "sync" ) import ( + "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/protocol" ) @@ -141,6 +143,29 @@ func (r *RPCInvocation) SetCallBack(c interface{}) { r.callBack = c } +func (r *RPCInvocation) ServiceKey() string { + intf := r.AttachmentsByKey(constant.INTERFACE_KEY, "") + if len(intf) == 0 { + return "" + } + buf := &bytes.Buffer{} + group := r.AttachmentsByKey(constant.GROUP_KEY, "") + if len(group) != 0 { + buf.WriteString(group) + buf.WriteString("/") + } + + buf.WriteString(intf) + + version := r.AttachmentsByKey(constant.VERSION_KEY, "") + if len(version) != 0 && version != "0.0.0" { + buf.WriteString(":") + buf.WriteString(version) + } + + return buf.String() +} + // ///////////////////////// // option // /////////////////////////