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
Custom Job ID #896
Comments
I don't follow your example. How is the jid relevant to perform? |
The |
Your model instance's ID has nothing to do with Sidekiq's job ID. You just want to do: TestWorker.perform_async(instance.id) def perform(id)
instance = Model.find(id)
instance.do_something
end Right or am I still confused? |
No, I mean something else. Sorry for being so confusing :) Here's my use case:
In my ruby code I can then easily control the flow with |
It looks like you're trying to determine when a job is done? There are two ways to do this:
|
I checked the status plugins, the issue is the same: if I didn't miss it, you cannot specify the job id manually, it is generated while calling Let's assume the following work flow:
Currently the job id is a return value from I don't want to do that, I want to deduct the job id dynamically (in my case from the instance id). And for that I need to be able to control the name if the jid. I think that is a valid use case, because the convention over configuration approach helps you to keep you code tidy. Or am I missing something here completely? |
The Job ID is not meant to be user-configurable; you are supposed to persist the returned jid if you want to poll or check for status later. The edge case you are missing is if there's a problem pushing the job to Redis. Right now this returns the jid or nil. In your case, you could poll for it in (3), not realizing it failed to push in the first place. |
Ah ok, now I understand the reasoning behind this. But imho a custom job id and the error handling is not 100% connected with each other. Meaning: if I specify a custom id, the But I agree this is a very specific feature request ... I'll be quite now and just use my fork :) |
@endymonium I think i follow what you’re looking to do. Basically just adding some sort either
The issue that were looking to “fix” is basically being able to find jobs easily, without having to store the random hex in the database. If i start a job, and I want to know its status, I must somehow keep that randomhex somewhere, within the scope of the process. im assuming your fork changes the jid generation in https://github.com/mperham/sidekiq/blob/67daa7a408b214d593100f782271ed108686c147/lib/sidekiq/job_util.rb#L49 |
Hi,
I needed to set the job id manually to able to bind a worker uniquely to a models instance.
The change I did (see https://github.com/endymonium/sidekiq/commit/5feb15a097fae2f3afec4db2ba54c70bc3f3e9c8) is not 100% clean, but perhaps something similar could be implemented? Or is there a better way to archive this?
Example
then
The text was updated successfully, but these errors were encountered: