Skip to content

Commit

Permalink
Merge pull request apache#747 from cvictory/proxy_invoker_fix
Browse files Browse the repository at this point in the history
ProxyInvoker cannot be extended
  • Loading branch information
zouyx authored Sep 11, 2020
2 parents d02f29d + a80f13f commit 73edb6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 9 additions & 0 deletions common/proxy/proxy_factory/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati
result.SetAttachments(invocation.Attachments())

url := pi.GetUrl()
//get providerUrl. The origin url may be is registry URL.
url = *getProviderURL(&url)

methodName := invocation.MethodName()
proto := url.Protocol
Expand Down Expand Up @@ -159,3 +161,10 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati
}
return result
}

func getProviderURL(url *common.URL) *common.URL {
if url.SubURL == nil {
return url
}
return url.SubURL
}
3 changes: 0 additions & 3 deletions registry/protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/common/proxy/proxy_factory"
"github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/config_center"
_ "github.com/apache/dubbo-go/config_center/configurator"
Expand Down Expand Up @@ -408,8 +407,6 @@ func newWrappedInvoker(invoker protocol.Invoker, url *common.URL) *wrappedInvoke

// Invoke remote service base on URL of wrappedInvoker
func (ivk *wrappedInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
// get right url
ivk.invoker.(*proxy_factory.ProxyInvoker).BaseInvoker = *protocol.NewBaseInvoker(ivk.GetUrl())
return ivk.invoker.Invoke(ctx, invocation)
}

Expand Down

0 comments on commit 73edb6b

Please sign in to comment.