From a6f63c2bac105e2aae2175288ac1d7634d034351 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 14 Apr 2021 23:57:45 +0300 Subject: [PATCH] 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. --- README.md | 2 +- app.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a394c5..34c04ad 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ HTTP_GW_REQUEST_TIMEOUT=duration - Timeout for request HTTP_GW_REBALANCE_TIMER=duration - Time between connections checks HTTP_GW_LISTEN_ADDRESS=host:port - Address to listen connections HTTP_GW_PEERS__ADDRESS=host:port - Address of NeoFS Node -HTTP_GW_PEERS__WEIGHT=float - Weight of NeoFS Node +HTTP_GW_PEERS__WEIGHT=float - Weight of NeoFS Node (1 if not specified) HTTP_GW_PPROF=bool - Enable/disable pprof (/debug/pprof) HTTP_GW_METRICS=bool - Enable/disable prometheus metrics endpoint (/metrics) HTTP_GW_LOGGER_FORMAT=string - Logger format diff --git a/app.go b/app.go index 1144de0..bafb90c 100644 --- a/app.go +++ b/app.go @@ -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)) }