scheduling sidekiq conditionally

221 views
Skip to first unread message

skynine

unread,
Nov 24, 2020, 3:12:07 PM11/24/20
to Sidekiq
Hi,

I need to schedule sidekiq worker based on updated_at of a record like below:
once a particular method returns success for a record in database spawn worker once after this:
- if `updated_at` less than 24 hours before `now` => worker should be spawned every hour
- if `updated_at` greater than 24 hours before `now` => worker should be spawned every 12 hours
- if `updated_at` more than 2 weeks ago => worker should not spawned anymore

I was looking at `sidekiq_retry_in` to accomplish this. but im not sure how to introduce the updated_at variable in this.

Any help would be much appreciated.
Thanks for reading!

Mike Perham

unread,
Nov 24, 2020, 3:20:50 PM11/24/20
to sid...@googlegroups.com
The closest thing Sidekiq has for that is this "dynamic jobs" section.


--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/dfb2e6bb-0eee-4dc1-ab80-a9f9aa834741n%40googlegroups.com.


--
Mike Perham – CEO, Contributed Systems
Smart, effective open source infrastructure for your apps.

skynine

unread,
Nov 24, 2020, 3:27:45 PM11/24/20
to Sidekiq
I don't know if Dynamic Jobs really fits my case. I may be missing something important here though.

But is this an option:

once the above mentioned method returns success:
- worker.perform(updated_at)
- within worker at end of perform:
   - if `updated_at` less than 24 hours before `now` => spawn worker after an hour
   - if `updated_at` greater than 24 hours before `now` =>  spawn worker after 12 hours
   -  if `updated_at` more than 2 weeks ago => do nothing


Im new to workers or sidekiq. so please forgive my ignorance.

Thanks 

Mike Perham

unread,
Nov 24, 2020, 3:29:29 PM11/24/20
to sid...@googlegroups.com
It sounds like basic scheduled jobs would work fine.


Reply all
Reply to author
Forward
0 new messages