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 2020/08/20 11:58:16 UTC

[GitHub] [dubbo-go] gaoxinge opened a new pull request #722: fix exporter append

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


   <!--  Thanks for sending a pull request! 
   -->
   
   **What this PR does**:
   
   - code format
   - fix bug in [service_config.go](https://github.com/apache/dubbo-go/blob/develop/config/service_config.go#L201-L225):
   
   <img width="910" alt="1" src="https://user-images.githubusercontent.com/16648345/90766628-6dddd500-e31e-11ea-80ee-dfe0616786b6.png">
   
   在`if len(regUrls) > 0`的分支里面,对`regUrls`进行循环,其中每个`regUrl`生成的`exporter`都应该放到`append`到`exporters`里面。但是现在的代码里面只有最后一个`append`到`exporters`里面了。
   
   所以应该在代码的`216`行下面加一个`c.exporters = append(c.exporters, exporter)`。


----------------------------------------------------------------
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 merged pull request #722: fix exporter append

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


   


----------------------------------------------------------------
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] zouyx commented on a change in pull request #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {

Review comment:
       In this case, `filterNames` is related to `filterName` .
   
   If some day, they dont have a relationship. I think it will cause a a hidden problem in the future...
   
   What do you think? @fangyincheng @AlexStocks 




----------------------------------------------------------------
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 #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {

Review comment:
       I revert this code.




----------------------------------------------------------------
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 #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {
-		return invoker
-	}
-	filtNames := strings.Split(filtName, ",")
-	next := invoker
+	filterName := invoker.GetUrl().GetParam(key, "")
+	filterNames := strings.Split(filterName, ",")
 
 	// The order of filters is from left to right, so loading from right to left
-
-	for i := len(filtNames) - 1; i >= 0; i-- {
-		flt := extension.GetFilter(filtNames[i])
+	next := invoker
+	for i := len(filterNames) - 1; i >= 0; i-- {

Review comment:
       If `filterName` equals `""`, then `filterNames` will equal to `[]`. Then because `filterNames` is empty string slice, and `len(filterNames)` equals zero, the circle will return immediately.

##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {

Review comment:
       If filterName equals "", then filterNames will equal to []. Then because filterNames is empty string slice, and len(filterNames) equals zero, the circle will return immediately.




----------------------------------------------------------------
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 #722: fix exporter append

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



##########
File path: config/service_config.go
##########
@@ -196,33 +196,31 @@ func (c *ServiceConfig) Export() error {
 			ivkURL.AddParam(constant.Tagkey, c.Tag)
 		}
 
-		var exporter protocol.Exporter
-
 		if len(regUrls) > 0 {
+			c.cacheMutex.Lock()
+			if c.cacheProtocol == nil {
+				logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL))
+				c.cacheProtocol = extension.GetProtocol("registry")
+			}
+			c.cacheMutex.Unlock()
+
 			for _, regUrl := range regUrls {
 				regUrl.SubURL = ivkURL
-
-				c.cacheMutex.Lock()
-				if c.cacheProtocol == nil {
-					logger.Infof(fmt.Sprintf("First load the registry protocol , url is {%v}!", ivkURL))
-					c.cacheProtocol = extension.GetProtocol("registry")
-				}
-				c.cacheMutex.Unlock()
-
-				invoker := extension.GetProxyFactory(providerConfig.ProxyFactory).GetInvoker(*regUrl)
-				exporter = c.cacheProtocol.Export(invoker)
+				invoker := proxyFactory.GetInvoker(*regUrl)
+				exporter := c.cacheProtocol.Export(invoker)
 				if exporter == nil {
-					panic(perrors.New(fmt.Sprintf("Registry protocol new exporter error,registry is {%v},url is {%v}", regUrl, ivkURL)))
+					return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL))

Review comment:
       This method requires an error when return:
   
   https://github.com/apache/dubbo-go/blob/4c483e0e4a5a2266eaf5df5e7b919a1560ba5722/config/service_config.go#L145  
   
   




----------------------------------------------------------------
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] fangyincheng commented on a change in pull request #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {
-		return invoker
-	}
-	filtNames := strings.Split(filtName, ",")
-	next := invoker
+	filterName := invoker.GetUrl().GetParam(key, "")
+	filterNames := strings.Split(filterName, ",")
 
 	// The order of filters is from left to right, so loading from right to left
-
-	for i := len(filtNames) - 1; i >= 0; i-- {
-		flt := extension.GetFilter(filtNames[i])
+	next := invoker
+	for i := len(filterNames) - 1; i >= 0; i-- {

Review comment:
       ![微信图片_20200902192638](https://user-images.githubusercontent.com/18375310/91975604-3fb2b900-ed52-11ea-84e6-7318ab6d7a8d.png)
   
   @gaoxinge




----------------------------------------------------------------
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 #722: fix exporter append

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



##########
File path: registry/registry.go
##########
@@ -30,30 +30,37 @@ import (
 // Registry Extension - Registry
 type Registry interface {
 	common.Node
-	//used for service provider calling , register services to registry
-	//And it is also used for service consumer calling , register services cared about ,for dubbo's admin monitoring.
+
+	// used for service provider calling, register services to registry
+	// And it is also used for service consumer calling, register
+	// services cared about, for dubbo's admin monitoring.
 	Register(url common.URL) error
 
 	// UnRegister is required to support the contract:
-	// 1. If it is the persistent stored data of dynamic=false, the registration data can not be found, then the IllegalStateException is thrown, otherwise it is ignored.
+	// 1. If it is the persistent stored data of dynamic=false, the
+	//    registration data can not be found, then the IllegalStateException
+	//    is thrown, otherwise it is ignored.
 	// 2. Unregister according to the full url match.
-	// url Registration information , is not allowed to be empty, e.g: dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
+	// url Registration information, is not allowed to be empty, e.g:
+	// dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
 	UnRegister(url common.URL) error
 
-	//When creating new registry extension,pls select one of the following modes.
-	//Will remove in dubbogo version v1.1.0
-	//mode1 : return Listener with Next function which can return subscribe service event from registry
-	//Deprecated!
-	//subscribe(event.URL) (Listener, error)
-
-	//Will replace mode1 in dubbogo version v1.1.0
-	//mode2 : callback mode, subscribe with notify(notify listener).
+	// When creating new registry extension, pls select one of the

Review comment:
       Fix.

##########
File path: registry/registry.go
##########
@@ -30,30 +30,37 @@ import (
 // Registry Extension - Registry
 type Registry interface {
 	common.Node
-	//used for service provider calling , register services to registry
-	//And it is also used for service consumer calling , register services cared about ,for dubbo's admin monitoring.
+
+	// used for service provider calling, register services to registry

Review comment:
       Fix.




----------------------------------------------------------------
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 #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {
-		return invoker
-	}
-	filtNames := strings.Split(filtName, ",")
-	next := invoker
+	filterName := invoker.GetUrl().GetParam(key, "")
+	filterNames := strings.Split(filterName, ",")
 
 	// The order of filters is from left to right, so loading from right to left
-
-	for i := len(filtNames) - 1; i >= 0; i-- {
-		flt := extension.GetFilter(filtNames[i])
+	next := invoker
+	for i := len(filterNames) - 1; i >= 0; i-- {

Review comment:
       Yes, you are right. I revert this code.




----------------------------------------------------------------
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] zouyx commented on a change in pull request #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {

Review comment:
       why do you remove this `if`?

##########
File path: registry/registry.go
##########
@@ -30,30 +30,37 @@ import (
 // Registry Extension - Registry
 type Registry interface {
 	common.Node
-	//used for service provider calling , register services to registry
-	//And it is also used for service consumer calling , register services cared about ,for dubbo's admin monitoring.
+
+	// used for service provider calling, register services to registry

Review comment:
       ```suggestion
   	// Register used for service provider calling, register services to registry
   ```

##########
File path: registry/registry.go
##########
@@ -30,30 +30,37 @@ import (
 // Registry Extension - Registry
 type Registry interface {
 	common.Node
-	//used for service provider calling , register services to registry
-	//And it is also used for service consumer calling , register services cared about ,for dubbo's admin monitoring.
+
+	// used for service provider calling, register services to registry
+	// And it is also used for service consumer calling, register
+	// services cared about, for dubbo's admin monitoring.
 	Register(url common.URL) error
 
 	// UnRegister is required to support the contract:
-	// 1. If it is the persistent stored data of dynamic=false, the registration data can not be found, then the IllegalStateException is thrown, otherwise it is ignored.
+	// 1. If it is the persistent stored data of dynamic=false, the
+	//    registration data can not be found, then the IllegalStateException
+	//    is thrown, otherwise it is ignored.
 	// 2. Unregister according to the full url match.
-	// url Registration information , is not allowed to be empty, e.g: dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
+	// url Registration information, is not allowed to be empty, e.g:
+	// dubbo://10.20.153.10/org.apache.dubbo.foo.BarService?version=1.0.0&application=kylin
 	UnRegister(url common.URL) error
 
-	//When creating new registry extension,pls select one of the following modes.
-	//Will remove in dubbogo version v1.1.0
-	//mode1 : return Listener with Next function which can return subscribe service event from registry
-	//Deprecated!
-	//subscribe(event.URL) (Listener, error)
-
-	//Will replace mode1 in dubbogo version v1.1.0
-	//mode2 : callback mode, subscribe with notify(notify listener).
+	// When creating new registry extension, pls select one of the

Review comment:
       Add method name in front of this sentence.




----------------------------------------------------------------
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] fangyincheng commented on a change in pull request #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {
-		return invoker
-	}
-	filtNames := strings.Split(filtName, ",")
-	next := invoker
+	filterName := invoker.GetUrl().GetParam(key, "")
+	filterNames := strings.Split(filterName, ",")
 
 	// The order of filters is from left to right, so loading from right to left
-
-	for i := len(filtNames) - 1; i >= 0; i-- {
-		flt := extension.GetFilter(filtNames[i])
+	next := invoker
+	for i := len(filterNames) - 1; i >= 0; i-- {

Review comment:
       if filterName == "",  
   then len(filterNames) == 1 and filterNames[0] == ""。
   At this point, the program should return.
   

##########
File path: config/service_config.go
##########
@@ -196,33 +196,31 @@ func (c *ServiceConfig) Export() error {
 			ivkURL.AddParam(constant.Tagkey, c.Tag)
 		}
 
-		var exporter protocol.Exporter
-
 		if len(regUrls) > 0 {
+			c.cacheMutex.Lock()
+			if c.cacheProtocol == nil {
+				logger.Infof(fmt.Sprintf("First load the registry protocol, url is {%v}!", ivkURL))
+				c.cacheProtocol = extension.GetProtocol("registry")
+			}
+			c.cacheMutex.Unlock()
+
 			for _, regUrl := range regUrls {
 				regUrl.SubURL = ivkURL
-
-				c.cacheMutex.Lock()
-				if c.cacheProtocol == nil {
-					logger.Infof(fmt.Sprintf("First load the registry protocol , url is {%v}!", ivkURL))
-					c.cacheProtocol = extension.GetProtocol("registry")
-				}
-				c.cacheMutex.Unlock()
-
-				invoker := extension.GetProxyFactory(providerConfig.ProxyFactory).GetInvoker(*regUrl)
-				exporter = c.cacheProtocol.Export(invoker)
+				invoker := proxyFactory.GetInvoker(*regUrl)
+				exporter := c.cacheProtocol.Export(invoker)
 				if exporter == nil {
-					panic(perrors.New(fmt.Sprintf("Registry protocol new exporter error,registry is {%v},url is {%v}", regUrl, ivkURL)))
+					return perrors.New(fmt.Sprintf("Registry protocol new exporter error, registry is {%v}, url is {%v}", regUrl, ivkURL))

Review comment:
       why return instead of panic




----------------------------------------------------------------
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 #722: fix exporter append

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



##########
File path: protocol/protocolwrapper/protocol_filter_wrapper.go
##########
@@ -68,21 +68,16 @@ func (pfw *ProtocolFilterWrapper) Destroy() {
 }
 
 func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker {
-	filtName := invoker.GetUrl().GetParam(key, "")
-	if filtName == "" {

Review comment:
       If `filterName` equals `""`, then `filterNames` will equal to `[]`. Then because `filterNames` is empty string slice, and `len(filterNames)` equals zero, the circle will return immediately.




----------------------------------------------------------------
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