Skip to content

Instantly share code, notes, and snippets.

@jhs
Created March 3, 2012 13:58
Show Gist options
  • Save jhs/1966269 to your computer and use it in GitHub Desktop.
Save jhs/1966269 to your computer and use it in GitHub Desktop.
Renewing CQS lease
message.on('heartbeat', function(percent) {
LOG.debug('heartbeat: ' + percent);
if(percent < 66)
return;
if(percent > 99) {
LOG.fatal('No more time for rake: ' + self.task);
return self.cancel();
}
// In the red zone
if(more_secs < MAX_SECS) {
LOG.info('Requesting ' + more_secs + ' more seconds');
message.visibility(more_secs, function(er) {
if(er)
LOG.warn('Failed to request ' + more_secs + ' seconds for rake: ' + self.task);
more_secs *= 2;
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment