JiaLiangoooo opened a new issue #1321:
URL: https://github.com/apache/dubbo-go/issues/1321


   正在使用的版本是1.5.5rc1
   目前正在尝试自定义loadbalance,但是balance里面会有一些自定义的参数.
   ```
   type Compare func(invocation protocol.Invocation, invoker protocol.Invoker) 
bool
   func NewBalance(compare Compare) *Balance {
        return &Balance{f: compare}
   }
   ```
   但是extension.SetLoadbalance支持的是`func () cluster.LoadBalance`
   ```
   // SetLoadbalance sets the loadbalance extension with @name
   // For example: random/round_robin/consistent_hash/least_active/...
   func SetLoadbalance(name string, fcn func() cluster.LoadBalance) {
        loadbalances[name] = fcn
   }
   
   // GetLoadbalance finds the loadbalance extension with @name
   func GetLoadbalance(name string) cluster.LoadBalance {
        if loadbalances[name] == nil {
                panic("loadbalance for " + name + " is not existing, make sure 
you have import the package.")
        }
   
        return loadbalances[name]()
   }
   
   ```
   所以有个疑问 为什么不使用`SetLoadbalance(name string, cluster.LoadBalance) `, 而使用`func 
() cluster.LoadBalance` ? 


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

Reply via email to