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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Extra" args which do not matter for job uniqueness #9
Comments
Or a |
Hi! It seems like there's a couple options here: a) The option that modifies gocraft/work to support "extra" args. The best way I can see to do this is to have a magic argument when enqueuing, such as
If this unique key is present, we'll use it instead of a full serialization of the args. b) Persist the ids and next_cursor_str outside of gocraft/work. You could persist them in redis, or perhaps sql (if you use that). May I ask, what do you do with all the ids once you get them? Save them anywhere? c) Use normal jobs instead of unique jobs, and keep track of the uniqueness yourself (in redis). You could check this unique k/v before enqueuing and clear when done. So, I'm a bit reluctant to just go with (a) because it's a bit magic and not immediately expected/intuitive. I'm also reluctant to go with (a) because I don't know how common this use-case is. Thoughts? |
I believe the uniqueKey should be overridable for when you have relatively large number of args, as the options otherwise are more work (usually premature optimization) than necessary to get the same effect. (a) actually looks good to me I'm storing/overriding In case of (c), do normal jobs use args for anything? What can go wrong when |
All jobs, unique and normal, serialize the args as json and store those bytes in redis. Redis can handle some fairly long values, but obviously you pay linearly for the bytes you use to transfer to redis and to encode/decode. |
I would like to use the unique jobs feature as well but also would like to be able to pass an unique ID that does not affect the uniqueness check to the job. |
Fixed by PR #110 |
Hi @cypriss,
Thanks for the work on work. 馃構
Case in point, in my current setup, I'm loading twitter followers with the job args:
If I'm rate limited by twitter API, I schedule a new job from within the current job with the args:
(I have to make a query for uniqueness at this time)
If I were to use
work
for background processing, it seems like embedding partial args like above will have to go unless:a) There's support to include "extra" args, which do not count towards job uniqueness; or
b) I use a reference to external cache. This sounds reasonably good for my case since the
ids
part can get pretty large.With (a) it would be guaranteed that there's only one followers checking job for a user with twitter_id 123456. The
next_cursor_str
andids
can move into the extra/cache args. What do you think? Are there breaking concerns about howwork
is implemented, or is this simple enough to do?I'm willing to take a stab at this with some guidance on what and how this would be possible.
The text was updated successfully, but these errors were encountered: