Implement default worker factory

This commit is contained in:
Jay
2026-04-17 18:59:13 -04:00
parent 34e9374a4b
commit 3a6c8901b5
3 changed files with 17 additions and 1 deletions

View File

@@ -67,6 +67,13 @@ func NewPool(config *PoolConfig, logger *slog.Logger) (*Pool, error) {
config = GetDefaultPoolConfig()
}
// if a custom factory is supplied, config.WorkerConfig is not used
if config.WorkerFactory == nil {
config.WorkerFactory = func(id string, stop <-chan struct{}) (*Worker, error) {
return NewWorker(id, stop, config.WorkerConfig)
}
}
if err := ValidatePoolConfig(config); err != nil {
return nil, err
}