[GitHub] [dubbo-go] hxmhlt commented on a change in pull request #476: Ftr: start provider with random port
hxmhlt commented on a change in pull request #476: URL: https://github.com/apache/dubbo-go/pull/476#discussion_r416289754 ## File path: config/service_config.go ## @@ -123,10 +143,14 @@ func (c *ServiceConfig) Export() error { regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() protocolConfigs := loadProtocol(c.Protocol, providerConfig.Protocols) - if len(protocolConfigs) == 0 { + protocolSize := len(protocolConfigs) Review comment: Why do this change? 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: us...@infra.apache.org
[GitHub] [dubbo-go] hxmhlt commented on a change in pull request #476: Ftr: start provider with random port
hxmhlt commented on a change in pull request #476: URL: https://github.com/apache/dubbo-go/pull/476#discussion_r416289534 ## File path: config/service_config.go ## @@ -105,6 +107,24 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { } } +// Get Random Port +func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { + ports := list.New() + for _, proto := range protocolConfigs { + if len(proto.Port) > 0 { + continue + } + + tcp, err := gxnet.ListenOnTCPRandomPort(proto.Ip) + if err != nil { + panic(perrors.New(fmt.Sprintf("Get tcp port error,err is {%v}", err))) + } + ports.PushBack(strings.Split(tcp.Addr().String(), ":")[1]) + defer tcp.Close() Review comment: move defer tcp.Close after line 118. ## File path: config/service_config.go ## @@ -123,10 +143,14 @@ func (c *ServiceConfig) Export() error { regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() protocolConfigs := loadProtocol(c.Protocol, providerConfig.Protocols) - if len(protocolConfigs) == 0 { + protocolSize := len(protocolConfigs) Review comment: Why do this change? ## File path: config/service_config_test.go ## @@ -23,6 +23,8 @@ import ( import ( "github.com/apache/dubbo-go/common/extension" + gxnet "github.com/dubbogo/gost/net" + "github.com/stretchr/testify/assert" Review comment: format 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: us...@infra.apache.org
[GitHub] [dubbo-go] hxmhlt commented on a change in pull request #476: Ftr: start provider with random port
hxmhlt commented on a change in pull request #476: URL: https://github.com/apache/dubbo-go/pull/476#discussion_r412792980 ## File path: config/service_config.go ## @@ -123,10 +134,12 @@ func (c *ServiceConfig) Export() error { regUrls := loadRegistries(c.Registry, providerConfig.Registries, common.PROVIDER) urlMap := c.getUrlMap() protocolConfigs := loadProtocol(c.Protocol, providerConfig.Protocols) - if len(protocolConfigs) == 0 { + protocolSize := len(protocolConfigs) + if protocolSize == 0 { logger.Warnf("The service %v's '%v' protocols don't has right protocolConfigs ", c.InterfaceName, c.Protocol) Review comment: what is the difference? 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: us...@infra.apache.org