vmihailenco / taskq

Golang asynchronous task/job queue with Redis, SQS, IronMQ, and in-memory backends

Home Page:https://taskq.uptrace.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose interfaces when possible

sruehl opened this issue · comments

When using this library it's hard to write mocks.
This is due to the fact that some methods expose structs.

func (q *Queue) Consumer() *taskq.Consumer {
	if q.consumer == nil {
		q.consumer = taskq.NewConsumer(q)
	}
	return q.consumer
}

see here

So I would propose to write interfaces whenever you have objects that provide interactions to allow writing mocks for the API without the need for doing something like described here.

I will prepare a PR containing the changes.