-
Notifications
You must be signed in to change notification settings - Fork 257
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
Extended functionality for Workers to specify queue to run on, and to perform after a duration #759
base: master
Are you sure you want to change the base?
Extended functionality for Workers to specify queue to run on, and to perform after a duration #759
Conversation
Thanks, this looks good! |
Yeah, don't know what I was thinking there 😅. Changed it to sleep the proper amount with the remaining time. |
@isaacdonaldson thanks for this!
Custom queues: In the original sidekiq it was used mostly for ordering. You ordered the critical queues first:
And sidekiq would iterate in-series over these, it would only pull from the next queue if the preceding one was empty -- creating a kind of a priority mechanism. I'm wondering if you experience the same and/or if you have other uses for custom queues? PS: every worker is defined as its own separate, statically typed job, so we do have separation between jobs, they just go into the same queue in redis (the same physical list: |
@jondot - Is there somewhere where I can check out your queue implementation? Would love to take a look :) I agree that a better defined trait like I don't think that extra/custom queues are a necessity, but I do think storing a unique 'queue label' with the job (in Postgres and Redis) could be a good idea for debugging/observability/human readability. That is what I was wanting to use them for, but it could also be optional. I also think that having a priority mechanism is quite important. I think using the same queue (Redis list/Postgres table) could be fine, as long as there is the ability to specify priority. I don't mind giving some feedback or expanding on what I mean once I can see the implementation :) |
Hi @isaacdonaldson - the final implementation is now merged, I hope you can take a look at the new code -- see if there's anything to improve from this PR into the new implementation |
Loco workers is using
sidekiq-rs
but not making it easy for users to use some of the features. Aliasing thesidekiq::worker::WorkerOpts
toloco_rs::worker::AppWorkerOpts
allows the ability to implementfn opts()...
for theloco_rs::worker::Worker
trait, and enables users to specify (and use) a custom queue for their worker to run on. As well, support is added to use theperform_in(...)
function that allows a worker to be run after a providedstd::time::Duration
has elapsed. Support forBackgroundQueue
(throughsidekiq-rs
),ForegroundBlocking
, andBackgroundAsync
was added, but could possibly not be ideal (ForegroundBlocking
does block 🤷♀️).Caveats: The specified queue for the worker needs to be defined in the
config.yml
file.