AlexStocks commented on code in PR #2941:
URL: https://github.com/apache/dubbo-go/pull/2941#discussion_r2217560149
##########
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 {
+ opts = append(opts, WithTpsLimitRate(i))
+ }
+ }
+ if c.TpsLimiter != "" {
+ opts = append(opts, WithTpsLimiter(c.TpsLimiter))
+ }
+ if c.TpsLimitStrategy != "" {
+ opts = append(opts, WithTpsLimitStrategy(c.TpsLimitStrategy))
+ }
+ if c.TpsLimitRejectedHandler != "" {
+ opts = append(opts,
WithTpsLimitRejectedHandler(c.TpsLimitRejectedHandler))
+ }
+ if c.ExecuteLimitRejectedHandler != "" {
+ opts = append(opts,
WithExecuteLimitRejectedHandler(c.ExecuteLimitRejectedHandler))
+ }
+ if c.Warmup != "" {
+ if d, err := time.ParseDuration(c.Warmup); 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]