fix(scheduler): add boundary validation and safety limits to worker count and queue size to prevent OOM

This commit is contained in:
duorameng
2026-06-26 16:52:59 +08:00
parent 6086772068
commit 33ea2fda7b
2 changed files with 24 additions and 0 deletions
+6
View File
@@ -208,9 +208,15 @@ func NewScheduler(config SchedulerConfig, handler SchedulerEventHandler) *Schedu
if config.WorkerCount <= 0 {
config.WorkerCount = 4
}
if config.WorkerCount > 1000 {
config.WorkerCount = 1000
}
if config.QueueSize <= 0 {
config.QueueSize = 100
}
if config.QueueSize > 50000 {
config.QueueSize = 50000
}
if config.RateInterval <= 0 {
config.RateInterval = 200 * time.Millisecond
}