mmeyer2k/monorail

dev-master 2019-05-15 18:17 UTC

This package is auto-updated.

Last update: 2024-11-16 05:58:11 UTC


README

Monorail is a single-threaded, redis-backed queue processor for when you want to do one thing really fast.

Install

composer require mmeyer2k/monorail

Basic Usage and Features

(new \mmeyer2k\Monorail\Queue)
    ->push(function () {
        echo "hello world";
    });

Priorities

Monorail supports numeric priority levels from 1 to 5 with 3 being default and 1 being highest priority.

(new \mmeyer2k\Monorail\Queue)
    ->priority(1)
    ->push(function () {
        // do something really important
    });

Tubes

(new \mmeyer2k\Monorail\Queue)
    ->tube('other tube')
    ->push(function () {
        echo "hello world";
    });

Delays

$seconds = 15;

(new \mmeyer2k\Monorail\Queue)
    ->delay($seconds)
    ->push(function () {
        echo "hello world";
    });

Re-queues

Supervisor

To make sure the queue worker is always running, supervisord is a great option.

[program:monorail-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /path/to/project/vendor/mmeyer2k/monorail/monorail work --tube=default
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/tmp/supervisor-monorail.log