maragudk / goqite

Go queue library built on SQLite and inspired by AWS SQS.
https://maragudk.github.io/goqite/
MIT License
435 stars 13 forks source link

Delivery delay mechanism #54

Open AsyncAlchemist opened 4 months ago

AsyncAlchemist commented 4 months ago

I'm interested in adding a delivery delay mechanism to your library to allow messages to be scheduled for future delivery. It would prevent messages from being delivered to runners until a specific time has been reached. After this time has passed, the message would be available to any runner to be delivered. If no time is set or the time scheduled is in the past, the behavior would be the library's existing behavior.

Please let me know if you'd be interested in receiving a PR for this improvement and if you have any guidelines you'd like me to follow. If so, feel free to assign me to the issue and I will begin work on this.

This improvement would most likely require a database migration.

markuswustenberg commented 4 months ago

Hi @AsyncAlchemist, thank you for your issue. I'm currently on summer holiday and won't be doing any work until August.

There's already a delay on the Message. Is that what you need? Or is it to delay jobs in that abstraction?

See https://pkg.go.dev/github.com/maragudk/goqite#Message

AsyncAlchemist commented 4 months ago

Ahhh, I see that now. I think this should work. My idea was to delay jobs until a certain time, so this should work.

By the way this feature is not documented anywhere. Would you let me to add an example of how to use this to the documentation?

markuswustenberg commented 4 months ago

It's documented under Send:

Send a Message to the queue with an optional delay.

https://pkg.go.dev/github.com/maragudk/goqite#Queue.Send

But definitely feel free to add a testable example, preferably named ExampleSend_delay. 😊