From 73a88c2965ca1334fa718ae2fb3b534bfe19fdfb Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 2 Jun 2022 17:06:08 +0300 Subject: [PATCH] [#1474] neofs-node/config: Remove `num` from the "grpc" section It isn't needed and can be replaced with additional checks during the iteration. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-node/config/grpc/config.go | 22 ++++++++++++++-------- config/example/node.env | 1 - config/example/node.json | 1 - config/example/node.yaml | 1 - 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/cmd/neofs-node/config/grpc/config.go b/cmd/neofs-node/config/grpc/config.go index 900b428c3c..865ee07b63 100644 --- a/cmd/neofs-node/config/grpc/config.go +++ b/cmd/neofs-node/config/grpc/config.go @@ -83,23 +83,29 @@ func (tls TLSConfig) UseInsecureCrypto() bool { return config.BoolSafe(tls.cfg, "use_insecure_crypto") } -// IterateEndpoints iterates over subsections ["0":"N") (N - "num" value) -// of "grpc" section of c, wrap them into Config and passes to f. +// IterateEndpoints iterates over subsections of "grpc" section of c, +// wrap them into Config and passes to f. +// +// Section names are expected to be consecutive integer numbers, starting from 0. // // Panics if N is not a positive number. func IterateEndpoints(c *config.Config, f func(*Config)) { c = c.Sub("grpc") - num := config.Uint(c, "num") - if num == 0 { - panic("no gRPC server configured") - } - - for i := uint64(0); i < num; i++ { + i := uint64(0) + for ; ; i++ { si := strconv.FormatUint(i, 10) sc := (*Config)(c.Sub(si)) + e := config.StringSafe((*config.Config)(sc), "endpoint") + if e == "" { + break + } + f(sc) } + if i == 0 { + panic("no gRPC server configured") + } } diff --git a/config/example/node.env b/config/example/node.env index 4a89fdf099..70ba0d607c 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -28,7 +28,6 @@ NEOFS_NODE_NOTIFICATION_KEY=/key/path NEOFS_NODE_NOTIFICATION_CA=/ca/path # gRPC section -NEOFS_GRPC_NUM=2 ## 0 server NEOFS_GRPC_0_ENDPOINT=s01.neofs.devenv:8080 ### TLS config diff --git a/config/example/node.json b/config/example/node.json index de515fd932..6fee13f487 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -51,7 +51,6 @@ } }, "grpc": { - "num": 2, "0": { "endpoint": "s01.neofs.devenv:8080", "tls": { diff --git a/config/example/node.yaml b/config/example/node.yaml index 676dba9507..223290868e 100644 --- a/config/example/node.yaml +++ b/config/example/node.yaml @@ -43,7 +43,6 @@ node: ca: "/ca/path" # path to optional CA certificate grpc: - num: 2 # total number of listener endpoints 0: endpoint: s01.neofs.devenv:8080 # endpoint for gRPC server tls: