[#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 <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-06-02 17:06:08 +03:00 committed by LeL
parent 0e28902b0f
commit 73a88c2965
4 changed files with 14 additions and 11 deletions

View file

@ -83,23 +83,29 @@ func (tls TLSConfig) UseInsecureCrypto() bool {
return config.BoolSafe(tls.cfg, "use_insecure_crypto") return config.BoolSafe(tls.cfg, "use_insecure_crypto")
} }
// IterateEndpoints iterates over subsections ["0":"N") (N - "num" value) // IterateEndpoints iterates over subsections of "grpc" section of c,
// of "grpc" section of c, wrap them into Config and passes to f. // 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. // Panics if N is not a positive number.
func IterateEndpoints(c *config.Config, f func(*Config)) { func IterateEndpoints(c *config.Config, f func(*Config)) {
c = c.Sub("grpc") c = c.Sub("grpc")
num := config.Uint(c, "num") i := uint64(0)
if num == 0 { for ; ; i++ {
panic("no gRPC server configured")
}
for i := uint64(0); i < num; i++ {
si := strconv.FormatUint(i, 10) si := strconv.FormatUint(i, 10)
sc := (*Config)(c.Sub(si)) sc := (*Config)(c.Sub(si))
e := config.StringSafe((*config.Config)(sc), "endpoint")
if e == "" {
break
}
f(sc) f(sc)
} }
if i == 0 {
panic("no gRPC server configured")
}
} }

View file

@ -28,7 +28,6 @@ NEOFS_NODE_NOTIFICATION_KEY=/key/path
NEOFS_NODE_NOTIFICATION_CA=/ca/path NEOFS_NODE_NOTIFICATION_CA=/ca/path
# gRPC section # gRPC section
NEOFS_GRPC_NUM=2
## 0 server ## 0 server
NEOFS_GRPC_0_ENDPOINT=s01.neofs.devenv:8080 NEOFS_GRPC_0_ENDPOINT=s01.neofs.devenv:8080
### TLS config ### TLS config

View file

@ -51,7 +51,6 @@
} }
}, },
"grpc": { "grpc": {
"num": 2,
"0": { "0": {
"endpoint": "s01.neofs.devenv:8080", "endpoint": "s01.neofs.devenv:8080",
"tls": { "tls": {

View file

@ -43,7 +43,6 @@ node:
ca: "/ca/path" # path to optional CA certificate ca: "/ca/path" # path to optional CA certificate
grpc: grpc:
num: 2 # total number of listener endpoints
0: 0:
endpoint: s01.neofs.devenv:8080 # endpoint for gRPC server endpoint: s01.neofs.devenv:8080 # endpoint for gRPC server
tls: tls: