← Back to Upcase

Constantly-refreshing sync with external API

(Joel Sutherland) #1

I have an application which needs to keep up to date with an external API. Currently, I’m using the “whenever” gem to maintain a cronjob which kicks off a task in the morning which has a while loop which loops until 11PM (the system only needs to be up-to-date during the day). The amount of time it takes to go through one cycle of the sync varies (so having an “every 15 minutes” cron task is not optimal). I’d like to minimize the “refresh rate”.

I’d much prefer to use something like delayed_job which automatically retries when the external service is temporarily unavailable. I considered having the task put itself back in the DJ queue when finishing, but that seems messy to me, and non-idomatic.

Can anyone think of the right tool/practice for the job?