2017 © Pedro Peláez
 

library redis-queue

Small library for using Redis as a job queue

image

equip/redis-queue

Small library for using Redis as a job queue

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Equip Redis Queue

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

A small library for using Redis as a job queue in Equip applications., (*2)

Installation

Use Composer., (*3)

composer require equip/redis-queue

Add the DefaultConfigurationSet configuration to your project., (*4)

Consuming

Consumers are written as commands using equip/command. See its documentation for more information., (*5)

To run consumers, use a runner like the example included in this repository. This runner uses two environmental variables, REDIS_HOST and REDIS_PORT, to point to the Redis server to use; they default to '127.0.0.1' and 6379, respectively. The runner takes a single required parameter: the Redis key representing the queue from which the consumer is to retrieve jobs., (*6)

REDIS_HOST=example.com REDIS_PORT=12345 ./bin/consume queue_name

Note that your runner will need to configure your Auryn Injector instance appropriately for it to be able to create instances of your consumer command classes and their dependencies., (*7)

Publishing

Jobs are published using an instance of the Publisher class. Configuration included in DefaultConfigurationSet should be sufficient to have Auryn generate an instance of it., (*8)

Here's an example of publishing a job from a domain class, where Acme\Command\FooCommand is a command class intended to function as a consumer., (*9)

namespace Acme;

use Acme\Command\FooCommand;
use Equip\Adr\DomainInterface;
use Equip\RedisQueue\Publisher;

class FooDomain implements DomainInterface
{
    private $publisher;

    public function __construct(Publisher $publisher)
    {
        $this->publisher = $publisher;
    }

    public function __invoke(array $input)
    {
        // ...

        $command_options = ['foo' => 'bar'];
        $this->publisher->publish(
            'queue_name',
            FooCommand::class,
            $command_options
        );
    }
}

To publish a job, the publish() method of the Publisher instance is invoked with these arguments:, (*10)

  • The first argument is a string containing the name of the queue, which must be a valid Redis key
  • The second argument is a string containing the fully-qualified name of a command class containing the logic for the job to execute
  • The third argument is an associative array of options to be used by an instance of the command class

The Versions

06/07 2016

dev-feature/abandon

dev-feature/abandon

Small library for using Redis as a job queue

  Sources   Download

MIT

The Requires

 

The Development Requires

27/02 2016

dev-master

9999999-dev

Small library for using Redis as a job queue

  Sources   Download

MIT

The Requires

 

The Development Requires

08/01 2016

0.1.0

0.1.0.0

Small library for using Redis as a job queue

  Sources   Download

MIT

The Requires

 

The Development Requires