mirror of
https://github.com/DullJZ/s3-balance.git
synced 2026-09-05 07:46:42 +08:00
Support hot update config
This commit is contained in:
@@ -87,7 +87,7 @@ func (b *Balancer) GetStrategy() string {
|
||||
// 允许在运行时更改负载均衡策略
|
||||
func (b *Balancer) SetStrategy(strategyName string) error {
|
||||
var strategy Strategy
|
||||
|
||||
|
||||
switch strategyName {
|
||||
case "round-robin":
|
||||
strategy = NewRoundRobinStrategy()
|
||||
@@ -100,11 +100,16 @@ func (b *Balancer) SetStrategy(strategyName string) error {
|
||||
default:
|
||||
return fmt.Errorf("unknown balancer strategy: %s", strategyName)
|
||||
}
|
||||
|
||||
|
||||
b.strategy = strategy
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateStrategy 更新负载均衡策略(热更新用)
|
||||
func (b *Balancer) UpdateStrategy(strategyName string) error {
|
||||
return b.SetStrategy(strategyName)
|
||||
}
|
||||
|
||||
// SetMetrics 设置指标服务
|
||||
func (b *Balancer) SetMetrics(metrics *metrics.Metrics) {
|
||||
b.metrics = metrics
|
||||
|
||||
Reference in New Issue
Block a user