We built sched.do for Yammer as an example open-sourced Rails application using the Yammer API. Like many services, Yammer API calls are subject to rate-limitations.
At times, the application would hit the Yammer API rate limit and encounter a 429 status code. To solve this, we leveraged delayed_job
's functionality of retrying failed jobs. Our goal was to set the retry time to just outside the rate-limit time window.
To accomplish this, we overrode the reschedule_at
and max_attempts
methods, which delayed_job
exposes for custom jobs. We also wanted to retry the job until success, so max_attempts
was also overridden.
Code example:
module YammerRateLimited