Skip to content

Instantly share code, notes, and snippets.

@Taluu
Created February 9, 2016 16:53

Revisions

  1. Taluu created this gist Feb 9, 2016.
    18 changes: 18 additions & 0 deletions sleep.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    <?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;
    }
    }