diff --git a/README.md b/README.md index f171917..a160df9 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ func init() { Concurrency: 2, Namespace: "resque:", Interval: 5.0, + PrefillParallelism: 0, } goworker.SetSettings(settings) goworker.Register("MyClass", myFunc) diff --git a/goworker.go b/goworker.go index cf2faad..e08fc50 100644 --- a/goworker.go +++ b/goworker.go @@ -23,19 +23,20 @@ var ( var workerSettings WorkerSettings type WorkerSettings struct { - QueuesString string - Queues queuesFlag - IntervalFloat float64 - Interval intervalFlag - Concurrency int - Connections int - URI string - Namespace string - ExitOnComplete bool - IsStrict bool - UseNumber bool - SkipTLSVerify bool - TLSCertPath string + QueuesString string + Queues queuesFlag + IntervalFloat float64 + Interval intervalFlag + Concurrency int + Connections int + URI string + Namespace string + ExitOnComplete bool + IsStrict bool + UseNumber bool + SkipTLSVerify bool + TLSCertPath string + PrefillParallelism int } func SetSettings(settings WorkerSettings) { @@ -61,7 +62,7 @@ func Init() error { } ctx = context.Background() - pool = newRedisPool(workerSettings.URI, workerSettings.Connections, workerSettings.Connections, time.Minute) + pool = newRedisPool(workerSettings.URI, workerSettings.Connections, workerSettings.Connections, time.Minute, workerSettings.PrefillParallelism) initialized = true } diff --git a/redis.go b/redis.go index 085993b..a0a1c00 100644 --- a/redis.go +++ b/redis.go @@ -31,8 +31,8 @@ func newRedisFactory(uri string) pools.Factory { } } -func newRedisPool(uri string, capacity int, maxCapacity int, idleTimout time.Duration) *pools.ResourcePool { - return pools.NewResourcePool(newRedisFactory(uri), capacity, maxCapacity, idleTimout) +func newRedisPool(uri string, capacity int, maxCapacity int, idleTimout time.Duration, prefillParallelism int) *pools.ResourcePool { + return pools.NewResourcePool(newRedisFactory(uri), capacity, maxCapacity, idleTimout, prefillParallelism) } func redisConnFromURI(uriString string) (*RedisConn, error) {