package rpcconfig import ( "strconv" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config" ) const ( subsection = "rpc" limitsSubsection = "limits" ) type LimitConfig struct { Methods []string MaxOps int64 } // Limits returns the "limits" config from "rpc" section. func Limits(c *config.Config) []LimitConfig { c = c.Sub(subsection).Sub(limitsSubsection) var limits []LimitConfig for i := uint64(0); ; i++ { si := strconv.FormatUint(i, 10) sc := c.Sub(si) methods := config.StringSliceSafe(sc, "methods") if len(methods) == 0 { break } if sc.Value("max_ops") == nil { panic("no max operations for method group") } limits = append(limits, LimitConfig{methods, config.IntSafe(sc, "max_ops")}) } return limits }