You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/01/25 10:02:48 UTC

[GitHub] [dubbo-go] yongjiapro opened a new pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

yongjiapro opened a new pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019


   <!--  Thanks for sending a pull request!
   Read https://github.com/apache/dubbo-go/blob/master/contributing.md before commit pull request. 
   -->
   
   **What this PR does**:
   
   Ftr: Add Prox ImplementFunc to allow override impl 
   
   重构Proxy,添加ImplementFunc函数,允许项目对Proxy的代理实现进行重新实现。
   
   **Which issue(s) this PR fixes**:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   
   在网关泛调用场景下,当前GenericService实现需要修改对返回数据的处理逻辑。
   目前ProxyFactory允许自定义注册,但其创建的proxy.Proxy无法重新实现。
   
   ```release-note
   Ftr: Add Proxy ImplementFunc to allow override impl 
   ```


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] gaoxinge commented on a change in pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
gaoxinge commented on a change in pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019#discussion_r564546057



##########
File path: common/proxy/proxy.go
##########
@@ -40,23 +40,47 @@ import (
 type Proxy struct {
 	rpc         common.RPCService
 	invoke      protocol.Invoker
-	callBack    interface{}
+	callback    interface{}
 	attachments map[string]string
-
-	once sync.Once
+	implement   ImplementFunc
+	once        sync.Once
 }
 
+type (
+	// ProxyOption a function to init Proxy with options
+	// nolint
+	ProxyOption func(p *Proxy)
+	// ImplementFunc function for proxy impl of RPCService functions
+	ImplementFunc func(p *Proxy, v common.RPCService)
+)
+
 var (
 	typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type()
 )
 
 // NewProxy create service proxy.
-func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[string]string) *Proxy {
-	return &Proxy{
+func NewProxy(invoke protocol.Invoker, callback interface{}, attachments map[string]string) *Proxy {
+	return NewProxyWith(invoke, callback, attachments,
+		WithProxyImplementFunc(DefaultProxyImplementFunc))
+}
+
+// NewProxy create service proxy.
+func NewProxyWith(invoke protocol.Invoker, callback interface{}, attachments map[string]string, opts ...ProxyOption) *Proxy {

Review comment:
       Rename `NewProxyWith` to `NewProxyWithOptions`.

##########
File path: common/proxy/proxy.go
##########
@@ -40,23 +40,47 @@ import (
 type Proxy struct {
 	rpc         common.RPCService
 	invoke      protocol.Invoker
-	callBack    interface{}
+	callback    interface{}
 	attachments map[string]string
-
-	once sync.Once
+	implement   ImplementFunc
+	once        sync.Once
 }
 
+type (
+	// ProxyOption a function to init Proxy with options
+	// nolint

Review comment:
       Remove `// nolint`.

##########
File path: common/proxy/proxy.go
##########
@@ -66,6 +90,29 @@ func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[str
 //  		Yyy func(ctx context.Context, args []interface{}, rsp *Zzz) error
 // 		}
 func (p *Proxy) Implement(v common.RPCService) {
+	p.once.Do(func() {
+		p.implement(p, v)
+		p.rpc = v
+	})
+

Review comment:
       Remove blank.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] cityiron merged pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
cityiron merged pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks commented on pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019#issuecomment-770714955


   pls change the target branch to 1.5


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] yongjiapro commented on pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
yongjiapro commented on pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019#issuecomment-772955141


   > pls change the target branch to 1.5
   
   Done


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] cityiron commented on pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
cityiron commented on pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019#issuecomment-773052238


   Tks, I will merge to 1.5 and add this for 1.5.6


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] cityiron merged pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
cityiron merged pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019


   


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] yongjiapro commented on pull request #1019: Refactor Proxy with ImplementFunc to allow override impl

Posted by GitBox <gi...@apache.org>.
yongjiapro commented on pull request #1019:
URL: https://github.com/apache/dubbo-go/pull/1019#issuecomment-767966135


   Rename and format code, Done


----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org