diff --git a/consumer.go b/consumer.go index 3afb41e..f5db326 100644 --- a/consumer.go +++ b/consumer.go @@ -52,7 +52,7 @@ func (s *Consumer) Queue(task core.QueuedMessage) error { //nolint:stylecheck if atomic.LoadInt32(&s.stopFlag) == 1 { return ErrQueueShutdown } - if s.count >= s.capacity { + if s.capacity > 0 && s.count >= s.capacity { return errMaxCapacity } diff --git a/options.go b/options.go index bdbf981..b1373de 100644 --- a/options.go +++ b/options.go @@ -8,7 +8,7 @@ import ( ) var ( - defaultQueueSize = 4096 + defaultCapacity = 0 defaultWorkerCount = runtime.NumCPU() defaultNewLogger = NewLogger() defaultFn = func(context.Context, core.QueuedMessage) error { return nil } @@ -87,7 +87,7 @@ type Options struct { func NewOptions(opts ...Option) *Options { o := &Options{ workerCount: defaultWorkerCount, - queueSize: defaultQueueSize, + queueSize: defaultCapacity, logger: defaultNewLogger, worker: nil, fn: defaultFn,