MCPcopy
hub / github.com/redis/go-redis / applyWorkerDefaults

Method applyWorkerDefaults

maintnotifications/config.go:346–364  ·  view source on GitHub ↗

applyWorkerDefaults calculates and applies worker defaults based on pool size

(poolSize int)

Source from the content-addressed store, hash-verified

344
345// applyWorkerDefaults calculates and applies worker defaults based on pool size
346func (c *Config) applyWorkerDefaults(poolSize int) {
347 // Calculate defaults based on pool size
348 if poolSize <= 0 {
349 poolSize = 10 * runtime.GOMAXPROCS(0)
350 }
351
352 // When not set: min(poolSize/2, max(10, poolSize/3)) - balanced scaling approach
353 originalMaxWorkers := c.MaxWorkers
354 c.MaxWorkers = min(poolSize/2, max(10, poolSize/3))
355 if originalMaxWorkers != 0 {
356 // When explicitly set: max(poolSize/2, set_value) - ensure at least poolSize/2 workers
357 c.MaxWorkers = max(poolSize/2, originalMaxWorkers)
358 }
359
360 // Ensure minimum of 1 worker (fallback for very small pools)
361 if c.MaxWorkers < 1 {
362 c.MaxWorkers = 1
363 }
364}
365
366// endpointDetectResolveTimeout bounds the DNS lookup performed by
367// DetectEndpointType so a slow or broken resolver cannot block client

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected