-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Test suite unclear on what happens when duplicate job is attempted #84
Comments
Check the readme https://github.com/mhenrixon/sidekiq-unique-jobs#logging |
Hm, logging is good, but what if I want to notify the user that the action they have tried failed? I mean, checking returned |
@ivanovv could you elaborate on your needs? It is possible to use the |
@mhenrixon sure! We have a process that uses external API to buy a resource for a company. Company has many users and one resource. We don't want users to be able to start a buying process if there is already one scheduled or running. At the same time we would like to notify a user that their attempt to buy a resource has failed. Make sense? |
Well if there is no jid returned then the job was most likely a duplicate and you could inform the user about the duplicate. Regarding how to do that exactly (I suppose you would like to mention what user is currently using the API) that is not something easily achieved with Sidekiq. unless MyAPIConsumer.perform_async(company_id: 1)
# notify user about that API is in use from another user
end If you want to keep track of who checks out the API then I recommend to use some type real database where you store these things on your side. It would be possible for the gem to collect that information for you using lua scripts but it isn't exactly straight forward with redis. |
Thanks a lot @mhenrixon! Will create a PR with changes to README later as it was quite a task to find that information in the repo :) |
The test suite says that a duplicate job is not added, which is the desired behavior.
But what else happens? Is an error raised? Is
false
returned? How does one know if success occurred or not? The nearest I can tell is thatperform
just won't return a job_id:The test suite doesn't make it clear how to check this, since it works by looking at the queue size, which definitely isn't the correct strategy for production, since jobs are being added and removed all the time.
The text was updated successfully, but these errors were encountered: