Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is the consumer started in the memqueue.NewQueue() method? #168

Open
ogbanugot opened this issue Jan 11, 2022 · 1 comment
Open

Why is the consumer started in the memqueue.NewQueue() method? #168

ogbanugot opened this issue Jan 11, 2022 · 1 comment

Comments

@ogbanugot
Copy link

I'm wondering why the consumer in https://github.com/vmihailenco/taskq/blob/v3/memqueue/queue.go.NewQueue() is started before returning the queue. Doesn't this go against the current design of other queues? Perhaps there is a reason why?

func NewQueue(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)
	}

	return q
}

`

@lzap
Copy link

lzap commented Jan 3, 2023

It is weird indeed, particularly when a Start method exists and it is exposed through the API. I realized I am calling it (twice).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants