MCPcopy
hub / github.com/yusing/godoxy / RemoveServer

Method RemoveServer

internal/net/gphttp/loadbalancer/loadbalancer.go:140–163  ·  view source on GitHub ↗
(srv types.LoadBalancerServer)

Source from the content-addressed store, hash-verified

138}
139
140func (lb *LoadBalancer) RemoveServer(srv types.LoadBalancerServer) {
141 lb.poolMu.Lock()
142 defer lb.poolMu.Unlock()
143
144 if _, ok := lb.pool.Get(srv.Key()); !ok {
145 return
146 }
147
148 lb.pool.Del(srv)
149
150 lb.sumWeight -= srv.Weight()
151 lb.rebalance()
152 lb.impl.OnRemoveServer(srv)
153
154 lb.l.Debug().
155 Str("action", "remove").
156 Str("server", srv.Name()).
157 Msgf("%d servers left", lb.pool.Size())
158
159 if lb.pool.Size() == 0 {
160 lb.task.Finish("no server left")
161 return
162 }
163}
164
165func (lb *LoadBalancer) rebalance() {
166 if lb.sumWeight == maxWeight {

Callers 1

addToLoadBalancerMethod · 0.95

Calls 9

rebalanceMethod · 0.95
GetMethod · 0.65
KeyMethod · 0.65
DelMethod · 0.65
WeightMethod · 0.65
OnRemoveServerMethod · 0.65
NameMethod · 0.65
SizeMethod · 0.65
FinishMethod · 0.45

Tested by

no test coverage detected