All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m10s
Pre-commit hooks / Pre-commit (push) Successful in 1m34s
Build / Build Components (push) Successful in 2m15s
Tests and linters / Tests with -race (push) Successful in 2m32s
Tests and linters / Run gofumpt (push) Successful in 2m33s
Tests and linters / gopls check (push) Successful in 2m37s
Tests and linters / Tests (push) Successful in 2m49s
Tests and linters / Lint (push) Successful in 2m51s
Tests and linters / Staticcheck (push) Successful in 2m57s
OCI image / Build container images (push) Successful in 5m12s
- Allow configuration of active RPC limits for method groups - Apply RPC limiting for all services except the control service Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
43 lines
780 B
Go
43 lines
780 B
Go
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
|
|
}
|
|
|
|
maxOps := config.IntSafe(sc, "max_ops")
|
|
if maxOps == 0 {
|
|
panic("no max operations for method group")
|
|
}
|
|
|
|
limits = append(limits, LimitConfig{methods, maxOps})
|
|
}
|
|
|
|
return limits
|
|
}
|