forked from TrueCloudLab/frostfs-http-gw
Rework connection artifacts choice logic
Signed-off-by: Pavel Korotkov <pavel@nspcc.ru>
This commit is contained in:
parent
fad05b76d4
commit
e3dbecf844
1 changed files with 5 additions and 9 deletions
|
@ -128,16 +128,12 @@ func (p *pool) ConnectionArtifacts() (client.Client, *token.SessionToken, error)
|
||||||
}
|
}
|
||||||
return nil, nil, errors.New("no healthy client")
|
return nil, nil, errors.New("no healthy client")
|
||||||
}
|
}
|
||||||
var i *int = nil
|
attempts := 3 * len(p.clientPacks)
|
||||||
for k := 0; k < 10; k++ {
|
for k := 0; k < attempts; k++ {
|
||||||
i_ := p.sampler.Next()
|
i := p.sampler.Next()
|
||||||
if p.clientPacks[i_].healthy {
|
if cp := p.clientPacks[i]; cp.healthy {
|
||||||
i = &i_
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if i != nil {
|
|
||||||
cp := p.clientPacks[*i]
|
|
||||||
return cp.client, cp.sessionToken, nil
|
return cp.client, cp.sessionToken, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil, nil, errors.New("no healthy client")
|
return nil, nil, errors.New("no healthy client")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue