Skip to content

Instantly share code, notes, and snippets.

@Taluu
Created February 9, 2016 16:53
Show Gist options
  • Save Taluu/a6591033e71a9b92a081 to your computer and use it in GitHub Desktop.
Save Taluu/a6591033e71a9b92a081 to your computer and use it in GitHub Desktop.
<?php
// snippet
class Processor
{
public function sleep(array $options)
{
if (null === $options['timeout']) {
return $this->processor instanceof SleepyInterface ? $this->processor->sleep($options) : true;
}
if ((time() - $options['reference']) <= $options['timeout']) {
return $this->processor instanceof SleepyInterface ? $this->processor->sleep($options) : true;
}
$this->logger->info('The process took too long. Killing the consumer...');
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment