2017 © Pedro Peláez
 

library queue

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

image

linio/queue

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  • Friday, July 20, 2018
  • by linio
  • Repository
  • 4 Watchers
  • 3 Stars
  • 459 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 11 % Grown

The README.md

Linio Queue

Latest Stable Version License Build Status Scrutinizer Code Quality, (*1)

Linio Queue abstracts work queues, used to distribute time-consuming tasks among multiple workers., (*2)

Install

The recommended way to install Linio Queue is through composer., (*3)

{
    "require": {
        "linio/queue": "~3.0"
    }
}

Tests

To run the test suite, you need install the dependencies via composer, then run PHPUnit., (*4)

$ composer install
$ phpunit

Usage

The library is very easy to use: first, you have to register the service. For Silex, a service provider is included. Just register it:, (*5)

<?php

use Linio\Component\Queue\QueueService;
use Linio\Component\Queue\Adapter;

$queue = new QueueService();
$queue->setAdapter(new Adapter\RabbitAdapter([
    'host' => 'localhost',
    'port' => 5672,
    'username' => 'guest',
    'password' => 'guest',
    'vhost' => '/'
]));

In order to create a work queue, you must extend the abstract class Job:, (*6)

<?php

use Linio\Component\Queue\Job;

class HelloWorldJob extends Job
{
    public function perform()
    {
        echo sprintf("Hello %s!\n", $this->payload);
        $this->finish();
    }
}

Note that you must always finish() a job to remove it from the queue. You can also fail() jobs. Now, in order to publish messages to a work queue:, (*7)

<?php

use Linio\Component\Queue\QueueService;

$queue = new QueueService();
$queue->add(new HelloWorldJob('John')); // "John" is the payload

And to consume messages from the work queue:, (*8)

<?php

use Linio\Component\Queue\QueueService;

$queue = new QueueService();
$queue->perform(new HelloWorldJob());

The Versions

20/07 2018

dev-master

9999999-dev

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rabbitmq queue distributed rabbit linio

28/06 2018

dev-dependabot/composer/phpunit/phpunit-tw-5.0|tw-7.0

dev-dependabot/composer/phpunit/phpunit-tw-5.0|tw-7.0

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rabbitmq queue distributed rabbit linio

03/12 2015

2.0.0

2.0.0.0

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rabbitmq queue distributed rabbit linio

01/10 2015

1.0.2

1.0.2.0

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rabbitmq queue distributed rabbit linio

26/09 2015

1.0.1

1.0.1.0

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rabbitmq queue distributed rabbit linio

17/03 2015

1.0.0

1.0.0.0

Abstracts work queues, used to distribute time-consuming tasks among multiple workers.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

rabbitmq queue distributed rabbit linio