-
-
Notifications
You must be signed in to change notification settings - Fork 381
feat: return job IDs from Worker::perform_later() for status tracking #1624
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
base: master
Are you sure you want to change the base?
feat: return job IDs from Worker::perform_later() for status tracking #1624
Conversation
|
i did not changed anything in the files who failed sanity 🤔 |
|
thanks @NewtTheWolf! . |
|
yes, i can take a look this week |
|
Hey @NewtTheWolf, Steps to Reproduce
Expected Actual i got: job: None |
|
hey @kaplanelad thats an expected result a Job ID ONLY gets returned if the Worker Supports it, if it does not Support JobId's it returns None I saw you used Async Worker and Async Worker dont Return or even Generate Job ID's if i'm right? i used this comment as Inspiration #1039 (comment)
|
| let dx = ctx.clone(); | ||
| tokio::spawn(async move { | ||
| if let Err(err) = Self::build(&dx).perform(args).await { | ||
| tracing::error!(err = err.to_string(), "worker failed to perform job"); | ||
| } | ||
| }); | ||
| None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokio::task::spawn returns a JoinHandle with an Id we could return here if we wanted.
There wouldn't be a real use for it today, but perhaps we could extend this in the future and utilize the handles to build a proper in-process queue provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that sounds intresting.
i think i can just implement, then there will no longer be an Option
Summary
This PR implements job ID returns from
Worker::perform_later()to enable job status tracking, addressing #1623.Changes
Queue::enqueue()to returnResult<Option<String>>instead ofResult<()>BackgroundWorker::perform_later()to returnResult<Option<String>>instead ofResult<()>Some(job_id)when using BackgroundQueue mode with a configured providerNonefor ForegroundBlocking, BackgroundAsync modes, or BackgroundQueue without a providerTesting
enqueuetests to verify job ID returnsqueue_enqueue_returns_job_idto verify behavior for different queue modescargo test --features bg_redis,bg_pg,bg_sqltDocumentation
Queue::enqueue()methoddocs-site/content/docs/processing/workers.mdNotes for Reviewers
Implements #1623