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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]