You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/09/15 06:02:15 UTC

[dubbo-go] branch config-enhance updated: feat(generic-inv): align generic inv interface with java (#1452)

This is an automated email from the ASF dual-hosted git repository.

laurence pushed a commit to branch config-enhance
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/config-enhance by this push:
     new 8d727d6  feat(generic-inv): align generic inv interface with java (#1452)
8d727d6 is described below

commit 8d727d630e0e02a48919e11c4058fe3716930d90
Author: XavierNiu <a...@nxw.name>
AuthorDate: Wed Sep 15 14:02:11 2021 +0800

    feat(generic-inv): align generic inv interface with java (#1452)
---
 common/proxy/proxy.go             | 4 ++--
 config/generic/generic_service.go | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go
index 819fe28..e1c6222 100644
--- a/common/proxy/proxy.go
+++ b/common/proxy/proxy.go
@@ -114,14 +114,13 @@ func (p *Proxy) GetInvoker() protocol.Invoker {
 func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) {
 	// check parameters, incoming interface must be a elem's pointer.
 	valueOf := reflect.ValueOf(v)
-	logger.Debugf("[Implement] reflect.TypeOf: %s", valueOf.String())
 
 	valueOfElem := valueOf.Elem()
 	typeOf := valueOfElem.Type()
 
 	// check incoming interface, incoming interface's elem must be a struct.
 	if typeOf.Kind() != reflect.Struct {
-		logger.Errorf("%s must be a struct ptr", valueOf.String())
+		logger.Errorf("The type of RPCService(=\"%T\") must be a pointer of a struct.", v)
 		return
 	}
 
@@ -152,6 +151,7 @@ func DefaultProxyImplementFunc(p *Proxy, v common.RPCService) {
 			start := 0
 			end := len(in)
 			invCtx := context.Background()
+			// retrieve the context from the first argument if existed
 			if end > 0 {
 				if in[0].Type().String() == "context.Context" {
 					if !in[0].IsNil() {
diff --git a/config/generic/generic_service.go b/config/generic/generic_service.go
index 677f97e..37bf948 100644
--- a/config/generic/generic_service.go
+++ b/config/generic/generic_service.go
@@ -21,9 +21,13 @@ import (
 	"context"
 )
 
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"
+)
+
 // GenericService uses for generic invoke for service call
 type GenericService struct {
-	Invoke       func(ctx context.Context, req []interface{}) (interface{}, error) `dubbo:"$invoke"`
+	Invoke       func(ctx context.Context, methodName string, types []string, args []hessian.Object) (interface{}, error) `dubbo:"$invoke"`
 	referenceStr string
 }