remove unused count variables
This commit is contained in:
parent
3981aa9b1a
commit
0e47f0d3c7
|
@ -17,7 +17,7 @@ type EngineGroup struct {
|
|||
policy GroupPolicy
|
||||
}
|
||||
|
||||
func NewGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) {
|
||||
func NewEngineGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) {
|
||||
var eg EngineGroup
|
||||
if len(policies) > 0 {
|
||||
eg.policy = policies[0]
|
||||
|
@ -73,9 +73,6 @@ func (eg *EngineGroup) Slave() *Engine {
|
|||
case 1:
|
||||
return eg.slaves[0]
|
||||
}
|
||||
if eg.s_count == 1 {
|
||||
return eg.slaves[0]
|
||||
}
|
||||
return eg.policy.Slave(eg)
|
||||
}
|
||||
|
||||
|
|
|
@ -68,16 +68,17 @@ func NewRoundRobinPolicy() *RoundRobinPolicy {
|
|||
}
|
||||
|
||||
func (policy *RoundRobinPolicy) Slave(g *EngineGroup) *Engine {
|
||||
var slaves = g.Slaves()
|
||||
var pos int
|
||||
policy.lock.Lock()
|
||||
policy.pos++
|
||||
if policy.pos >= g.s_count {
|
||||
if policy.pos >= len(slaves) {
|
||||
policy.pos = 0
|
||||
}
|
||||
pos = policy.pos
|
||||
policy.lock.Unlock()
|
||||
|
||||
return g.Slaves()[pos]
|
||||
return slaves[pos]
|
||||
}
|
||||
|
||||
type WeightRoundRobinPolicy struct {
|
||||
|
|
Loading…
Reference in New Issue