2017 © Pedro Peláez
 

library job-queue

Library to process jobs using Beanstalk.

image

burriko/job-queue

Library to process jobs using Beanstalk.

  • Thursday, March 17, 2016
  • by burriko
  • Repository
  • 2 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Job Queue

Build Status, (*1)

Work in progress library to easily push jobs on to a queue so they can be processed outside of the web request. Currently only supports Beanstalk queues. API will break regularly until v1., (*2)

Usage

Firstly you need to create an instance of a Queue., (*3)

$pheanstalk = new Pheanstalk\Pheanstalk('localhost');
$queue = new JobQueue\BeanstalkQueue($pheanstalk, 'email_queue');

Creating jobs

You can then push Jobs on to the Queue., (*4)

$job = new JobQueue\Job('EmailClient', ['client_id' => $id]);
$queue->push($job);

This assumes that you have an EmailClient class with a method named handle that takes an argument of client_id. This will be called later when the job is retrieved from the queue and executed., (*5)

Processing the queue

This will listen for new jobs to be pushed to the queue, and then execute them., (*6)

$runner = new JobQueue\JobRunner();
$worker = new JobQueue\QueueWorker($queue, $runner);

$worker->processQueue();

To just process the next job you can do this., (*7)

$worker->processNextJob();

You can see what the QueueWorker is doing by passing in a logger that implements psr/log., (*8)

$runner = new JobQueue\JobRunner();
$logger = new Monolog\Logger('queue');
$worker = new JobQueue\QueueWorker($queue, $runner, $logger);

The Versions

17/03 2016

dev-master

9999999-dev https://github.com/burriko/job-queue

Library to process jobs using Beanstalk.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/08 2015

0.1.0

0.1.0.0 https://github.com/burriko/job-queue

Library to process jobs using Beanstalk.

  Sources   Download

MIT

The Requires

 

The Development Requires