AlexStocks commented on code in PR #2941: URL: https://github.com/apache/dubbo-go/pull/2941#discussion_r2217560109
########## server/options.go: ########## @@ -948,3 +949,82 @@ func SetProtocols(pros map[string]*global.ProtocolConfig) ServiceOption { opts.Protocols = pros } } + +func GetProviderOptionsFromConfig(c *global.ServiceConfig) []ServiceOption { + var opts []ServiceOption + + if c.Interface != "" { + opts = append(opts, WithInterface(c.Interface)) + } + if c.Group != "" { + opts = append(opts, WithGroup(c.Group)) + } + if c.Version != "" { + opts = append(opts, WithVersion(c.Version)) + } + if c.Serialization != "" { + opts = append(opts, WithSerialization(c.Serialization)) + } + if len(c.ProtocolIDs) > 0 { + opts = append(opts, WithProtocolIDs(c.ProtocolIDs)) + } + if len(c.RegistryIDs) > 0 { + opts = append(opts, WithRegistryIDs(c.RegistryIDs)) + } + if c.Filter != "" { + opts = append(opts, WithFilter(c.Filter)) + } + if c.Token != "" { + opts = append(opts, WithToken(c.Token)) + } + if c.Tag != "" { + opts = append(opts, WithTag(c.Tag)) + } + if c.Cluster != "" { + opts = append(opts, WithCluster(c.Cluster)) + } + if c.Loadbalance != "" { + opts = append(opts, WithLoadBalance(c.Loadbalance)) + } + if c.Auth != "" { + opts = append(opts, WithAuth(c.Auth)) + } + if c.NotRegister { + opts = append(opts, WithNotRegister()) + } + if c.ParamSign != "" { + opts = append(opts, WithParamSign(c.ParamSign)) + } + if c.Retries != "" { + if i, err := strconv.Atoi(c.Retries); err == nil { + opts = append(opts, WithRetries(i)) + } + } + if c.ExecuteLimit != "" { + opts = append(opts, WithExecuteLimit(c.ExecuteLimit)) + } + if c.TpsLimitRate != "" { + if i, err := strconv.Atoi(c.TpsLimitRate); err == nil { Review Comment: 这里是不是应该加个 else 分支,出错时加上一个 error log? -- 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. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org