Skip to content

Commit

Permalink
fix(memqueue): Dont automaticaly start consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
rymurr committed Nov 27, 2024
1 parent 2956d04 commit baf5faf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions memqueue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,21 @@ type Queue struct {
var _ taskq.Queue = (*Queue)(nil)

func NewQueue(opt *taskq.QueueOptions) *Queue {
return NewQueueMaybeConsumer(true, opt)
}

func NewQueueMaybeConsumer(startConsumer bool, opt *taskq.QueueOptions) *Queue {
opt.Init()

q := &Queue{
opt: opt,
}

q.consumer = taskq.NewConsumer(q)
if err := q.consumer.Start(context.Background()); err != nil {
panic(err)
if startConsumer {
if err := q.consumer.Start(context.Background()); err != nil {
panic(err)
}
}

return q
Expand Down

0 comments on commit baf5faf

Please sign in to comment.