app: use 1 for weight if not specified or wrong

If we have a number of nodes with unspecified weights they'd all be treated
equal which seems to be fair.
This commit is contained in:
Roman Khimov 2021-04-14 23:57:45 +03:00 committed by Roman Khimov
parent f019c97ce8
commit a6f63c2bac
2 changed files with 4 additions and 1 deletions

3
app.go
View file

@ -108,6 +108,9 @@ func newApp(ctx context.Context, opt ...Option) App {
if address == "" {
break
}
if weight <= 0 { // unspecified or wrong
weight = 1
}
pb.AddNode(address, weight)
a.log.Info("add connection", zap.String("address", address), zap.Float64("weight", weight))
}