-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi @maxcountryman !
I am trying to separate job enqueuing/scheduling from processing according to different environments. It would be really helpful to have some utility functions here to ease this process. I can work on them if the design seems ok to you!
Since Job has all its attributes private to the module, the only way to create a worker or scheduler is to either keep a reference to the queue used in the job creation (since I want DLQ configured) OR expose some kind of new_scheduler and new_worker that does not "run" it.
Currently, I need to keep a job reference in a global state (like Axum state) so that I can enqueue/schedule jobs from other parts of the code. But the place where initialization happens and where I have a reference for the Queue are kind of distant as to say. And the place where I start running workers/schedulers is where I have the same CancellationToken and shutdown signal handlers. So, it would facilitate a lot to have these new_worker and new_scheduler there without having to keep queues some in the global state.
IMHO, this would also make other parts of the code cleaner (like in JobHandle where you cannot reuse this creation).
If that is okay I can open a PR.
Thanks for this incredible work!