From 4e0100bbe90660b060c13f25a75fc8405fc63d06 Mon Sep 17 00:00:00 2001 From: felipe andrade <130432649+felipe-op@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:19:13 -0700 Subject: [PATCH] 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 --- proxyd/proxyd/server.go | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/proxyd/proxyd/server.go b/proxyd/proxyd/server.go index 2c45aa7..c03d6de 100644 --- a/proxyd/proxyd/server.go +++ b/proxyd/proxyd/server.go @@ -31,18 +31,19 @@ import ( ) const ( - ContextKeyAuth = "authorization" - ContextKeyReqID = "req_id" - ContextKeyXForwardedFor = "x_forwarded_for" - MaxBatchRPCCallsHardLimit = 100 - cacheStatusHdr = "X-Proxyd-Cache-Status" - defaultRPCTimeout = 10 * time.Second - defaultBodySizeLimit = 256 * opt.KiB - defaultWSHandshakeTimeout = 10 * time.Second - defaultWSReadTimeout = 2 * time.Minute - defaultWSWriteTimeout = 10 * time.Second - maxRequestBodyLogLen = 2000 - defaultMaxUpstreamBatchSize = 10 + ContextKeyAuth = "authorization" + ContextKeyReqID = "req_id" + ContextKeyXForwardedFor = "x_forwarded_for" + DefaultMaxBatchRPCCallsLimit = 100 + MaxBatchRPCCallsHardLimit = 1000 + cacheStatusHdr = "X-Proxyd-Cache-Status" + defaultRPCTimeout = 10 * time.Second + defaultBodySizeLimit = 256 * opt.KiB + defaultWSHandshakeTimeout = 10 * time.Second + defaultWSReadTimeout = 2 * time.Minute + defaultWSWriteTimeout = 10 * time.Second + maxRequestBodyLogLen = 2000 + defaultMaxUpstreamBatchSize = 10 ) var emptyArrayResponse = json.RawMessage("[]") @@ -108,7 +109,11 @@ func NewServer( maxUpstreamBatchSize = defaultMaxUpstreamBatchSize } - if maxBatchSize == 0 || maxBatchSize > MaxBatchRPCCallsHardLimit { + if maxBatchSize == 0 { + maxBatchSize = DefaultMaxBatchRPCCallsLimit + } + + if maxBatchSize > MaxBatchRPCCallsHardLimit { maxBatchSize = MaxBatchRPCCallsHardLimit }