2017 © Pedro Peláez
 

library worker-bundle

Symfony2 Bundle to use queue with workers

image

riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  • Monday, April 23, 2018
  • by rcambien
  • Repository
  • 3 Watchers
  • 6 Stars
  • 42,047 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 24 Versions
  • 4 % Grown

The README.md

README

Build Status, (*1)

What is Riverline\WorkerBundle

Riverline\WorkerBundle add abstraction to queue providers and allow to create Workers to consume queue workload., (*2)

Requirements

  • PHP 5.3
  • Symfony 2.x

Installation

Riverline\WorkerBundle is compatible with composer and any prs-0 autoloader, (*3)

Configuration

riverline_worker:
    providers:
        predis:
            class: Riverline\WorkerBundle\Provider\PRedis
            arguments:
                - { host: redis.example.com }
        sqs: #v1
            class: Riverline\WorkerBundle\Provider\AwsSQS
            arguments:
                - { key: xxxxxx, secret: xxxxx }
                - sqs.eu-west-1.amazonaws.com
        sqs: #v3
            class: Riverline\WorkerBundle\Provider\AwsSQSv3
            arguments:
                -
                    version: "latest"
                    region: "us-west-2"
                    credentials:
                        key: "xxxxxx"
                        secret: "xxxxxx"
        gearman:
            class: Riverline\WorkerBundle\Provider\Gearman
            arguments:
                - [ gearman1.example.com, gearman2.examplet.com ]
        amqp: ## WIP
            class: Riverline\WorkerBundle\Provider\AMQP
        semaphore:
            class: Riverline\WorkerBundle\Provider\Semaphore
        activemq:
            class: Riverline\WorkerBundle\Provider\ActiveMQ
            arguments:
                - tcp://localhost:61613
                - login
                - passcode
                - false        # Boolean indicates if message is persistent
                - false        # Boolean indicates if broker statistics plugin is enabled http://activemq.apache.org/statisticsplugin.html
                - true         # Boolean indicates if sync mode is enabled

    queues:
        queue1:
            name: ThisIsMyQueue
            provider: predis
        queue2:
            name: https://eu-west-1.queue.amazonaws.com/xxxxxx/xxxx
            provider: sqs

Usage

You can access any configured provider or queue through the Symfony Container, (*4)

<?php

$provider = $this->get('riverline_worker.provider.predis');
$provider->put('ThisIsMyQueue', 'Hello World');

$queue = $this->get('riverline_worker.queue.queue1');
echo $queue->count()." item(s) in the queue";

You can easily create Workers, (*5)

<?php

// src/Acme/DemoBundle/Command/DemoWorkerCommand.php

namespace Acme\DemoBundle\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Riverline\WorkerBundle\Command\Worker;
use Riverline\WorkerBundle\Command\WorkerControlCodes;

class DemoWorkerCommand extends Worker
{
    protected function configureWorker()
    {
        $this
            // Queue name from the configuration
            ->setQueueName('queue1')

            // Inhered Command methods
            ->setName('demo-worker')
            ->setDescription('Test a worker')
        ;
    }

    protected function executeWorker(InputInterface $input, OutputInterface $output, $workload)
    {
        $output->writeln($workload);

        // Stop worker and dot not process other workloads
        if ($someReasonToStopAndExit)
        {
            return WorkerControlCodes::STOP_EXECUTION;
        }

        // else continue
        return WorkerControlCodes::CAN_CONTINUE;
    }
}

Then you can launch your worker like any other command, (*6)

$ php app/console demo-worker
Hello World

You can pass options., (*7)

$ php app/console --worker-wait-timeout=60 --worker-limit=10 --memory-limit=128 --worker-exit-on-exception

This command wait 60 seconds for a workload from the queue, will process a maximum of 10 workloads or exit when usaed memory exceed 128Mb and exit if the executeWorker() throw an exception., (*8)

The Versions

23/04 2018

dev-master

9999999-dev https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

23/04 2018

2.0.4

2.0.4.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

16/02 2018

2.0.3

2.0.3.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

08/02 2018

2.0.2

2.0.2.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

16/01 2018

2.0.1

2.0.1.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

16/01 2018

dev-develop

dev-develop https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

11/01 2018

2.0.0

2.0.0.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

05/12 2017

1.1.13

1.1.13.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

10/09 2017

1.1.12

1.1.12.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

18/04 2017

1.1.11

1.1.11.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

11/08 2016

1.1.10

1.1.10.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

18/03 2016

1.1.9

1.1.9.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

17/03 2016

1.1.8

1.1.8.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

20/04 2015

1.1.7

1.1.7.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

16/04 2015

1.1.6

1.1.6.0 https://github.com/Riverline/worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

07/03 2014

1.1.5

1.1.5.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

21/11 2013

1.1.4

1.1.4.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

26/07 2013

1.1.3

1.1.3.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

26/06 2013

1.1.2

1.1.2.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

09/04 2013

1.1.1

1.1.1.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

26/03 2013

1.1.0

1.1.0.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

04/03 2013

1.0.2

1.0.2.0 https://bitbucket.org/webrivage/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien
by Sebastien Porati

symfony2 bundle queue worker

21/08 2012

1.0.1

1.0.1.0 https://github.com/rcambien/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien

symfony2 bundle queue worker

20/08 2012

1.0.0

1.0.0.0 https://github.com/rcambien/riverline-worker-bundle

Symfony2 Bundle to use queue with workers

  Sources   Download

MIT

The Requires

 

The Development Requires

by Romain Cambien

symfony2 bundle queue worker