feat(proxyd): make max batch size hard limit 1000 and default 100 (#7719)

* feat: make max batch size hard limit 1000 and default 100

* nit: rename const
This commit is contained in:
felipe andrade 2023-10-17 13:19:13 -07:00 committed by GitHub
parent 9e1c96e9c5
commit 4e0100bbe9

@ -31,18 +31,19 @@ import (
) )
const ( const (
ContextKeyAuth = "authorization" ContextKeyAuth = "authorization"
ContextKeyReqID = "req_id" ContextKeyReqID = "req_id"
ContextKeyXForwardedFor = "x_forwarded_for" ContextKeyXForwardedFor = "x_forwarded_for"
MaxBatchRPCCallsHardLimit = 100 DefaultMaxBatchRPCCallsLimit = 100
cacheStatusHdr = "X-Proxyd-Cache-Status" MaxBatchRPCCallsHardLimit = 1000
defaultRPCTimeout = 10 * time.Second cacheStatusHdr = "X-Proxyd-Cache-Status"
defaultBodySizeLimit = 256 * opt.KiB defaultRPCTimeout = 10 * time.Second
defaultWSHandshakeTimeout = 10 * time.Second defaultBodySizeLimit = 256 * opt.KiB
defaultWSReadTimeout = 2 * time.Minute defaultWSHandshakeTimeout = 10 * time.Second
defaultWSWriteTimeout = 10 * time.Second defaultWSReadTimeout = 2 * time.Minute
maxRequestBodyLogLen = 2000 defaultWSWriteTimeout = 10 * time.Second
defaultMaxUpstreamBatchSize = 10 maxRequestBodyLogLen = 2000
defaultMaxUpstreamBatchSize = 10
) )
var emptyArrayResponse = json.RawMessage("[]") var emptyArrayResponse = json.RawMessage("[]")
@ -108,7 +109,11 @@ func NewServer(
maxUpstreamBatchSize = defaultMaxUpstreamBatchSize maxUpstreamBatchSize = defaultMaxUpstreamBatchSize
} }
if maxBatchSize == 0 || maxBatchSize > MaxBatchRPCCallsHardLimit { if maxBatchSize == 0 {
maxBatchSize = DefaultMaxBatchRPCCallsLimit
}
if maxBatchSize > MaxBatchRPCCallsHardLimit {
maxBatchSize = MaxBatchRPCCallsHardLimit maxBatchSize = MaxBatchRPCCallsHardLimit
} }