2017 © Pedro PelĆ”ez
 

library qutee

Simple queue manager and task processor for PHP

image

anorgan/qutee

Simple queue manager and task processor for PHP

  • Wednesday, February 15, 2017
  • by anorgan
  • Repository
  • 13 Watchers
  • 56 Stars
  • 603 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 9 Forks
  • 9 Open issues
  • 9 Versions
  • 36 % Grown

The README.md

QuTee

Build Status Coverage Status, (*1)

Simple queue manager and task processor for PHP using Beanstalkd, Redis or MySQL as backend. Event interface is provided for your logging or statsd-ing needs., (*2)

Example

``` php <?php /* * Bootstrap / DIC */ $beanstalkdParams = array( 'host' => '127.0.0.1', 'port' => 11300 ); $queuePersistor = new Qutee\Persistor\Beanstalk(); $queuePersistor->setOptions($beanstalkdParams);, (*3)

// or..., (*4)

$redisParams = array( 'host' => '127.0.0.1', 'port' => 6379 ); $queuePersistor = new Qutee\Persistor\Redis(); $queuePersistor->setOptions($redisParams);, (*5)

// or..., (*6)

$pdoParams = array( 'dsn' => 'mysql:host=127.0.0.1;dbname=test;charset=utf8', 'username' => 'root', 'password' => '', 'table_name'=> 'queue' ); $queuePersistor = new Qutee\Persistor\Pdo(); $queuePersistor->setOptions($pdoParams);, (*7)

$queue = new Queue(); $queue->setPersistor($queuePersistor);, (*8)

/* * App */, (*9)

// Create Task $task = new Task; $task ->setName('Acme/DeleteFolder') ->setData(array( 'path' => '/usr', )) ->setPriority(Task::PRIORITY_HIGH);, (*10)

// Queue it $queue->addTask($task);, (*11)

// Or do this in one go Task::create('Acme/DeleteFolder', array('path' => '/usr'), Task::PRIORITY_HIGH);, (*12)


``` php <?php // Worker - process all queues $worker = new Worker; while (true) { try { $worker->run(); } catch (Exception $e) { echo $e->getMessage(); } } // Or, with more configuration $worker = new Worker; $worker ->setInterval(30) // Run every 30 seconds ->setPriority(Task::PRIORITY_HIGH) // Will only do tasks of this priority ; while (true) { try { if (null !== ($task = $worker->run())) { echo 'Ran task: '. $task->getName() . PHP_EOL; } } catch (Exception $e) { echo 'Error: '. $e->getMessage() . PHP_EOL; } }

Logging example

``` php // Initialize queue with persistor $queue = new Qutee\Queue();, (*13)

// Setup the dispatcher, and register your subscriber $dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher; $dispatcher->addSubscriber(new QuteeEventSubscriber()); $queue->setEventDispatcher($dispatcher);, (*14)

// The subscriber: class QuteeEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { public static function getSubscribedEvents() { return array( \Qutee\Queue::EVENT_ADD_TASK => array( 'addTask', 0 ), \Qutee\Worker::EVENT_START_PROCESSING_TASK => array( 'processTask', 0 ), \Qutee\Worker::EVENT_END_PROCESSING_TASK => array( 'processTaskEnd', 0 ), ); }, (*15)

public function addTask(Qutee\Event $event)
{
    $this->log('Added task: '. $event->getTask()->getName());
}

public function processTask(Qutee\Event $event)
{
    $this->log('Processing task '. $event->getTask()->getName() .' started');
}

public function processTaskEnd(Qutee\Event $event)
{
    $this->log('Processing task '. $event->getTask()->getName() .' finished, lasted '. ($event->getArgument('elapsedTime') / 1000) .' seconds');
}

protected function log($message)
{
    file_put_contents(__DIR__ .'/events.log', $message . PHP_EOL, FILE_APPEND);
}

}, (*16)

```, (*17)

Notes

  • Use supervisord or similar for process monitoring / babysitting

TODO, (*18)

The Versions

15/02 2017

dev-master

9999999-dev https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

 

The Development Requires

by Marin Crnković

task redis queue mysql job worker background beanstalkd qutee

15/02 2017

v0.9.3

0.9.3.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

 

The Development Requires

by Marin Crnković

task redis queue mysql job worker background beanstalkd qutee

04/12 2015

v0.9.2

0.9.2.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

 

The Development Requires

by Marin Crnković

task redis queue mysql job worker background beanstalkd qutee

03/12 2015

v0.9.1

0.9.1.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

 

The Development Requires

by Marin Crnković

task redis queue mysql job worker background beanstalkd qutee

19/05 2014

v0.9.0

0.9.0.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

 

by Marin Crnković

task redis queue mysql job worker background beanstalkd qutee

26/04 2014

v0.8.0

0.8.0.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

  • php >=5.3.3

 

by Marin Crnković

task redis queue job worker background qutee

10/04 2013

v0.7.1

0.7.1.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

  • php >=5.3.3

 

by Marin Crnković

task redis queue job worker background qutee

31/01 2013

v0.7.0

0.7.0.0 https://github.com/anorgan/qutee

Simple queue manager and task processor for PHP

  Sources   Download

LGPL-2.1+

The Requires

  • php >=5.3.3

 

by Marin Crnković

task redis queue job worker background qutee