2017 © Pedro Peláez
 

library queues

A set of queue helpers

image

arrounded/queues

A set of queue helpers

  • Tuesday, September 15, 2015
  • by bramdevries
  • Repository
  • 3 Watchers
  • 0 Stars
  • 277 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Arrounded/queues

An optionated helper for dealing with queues, (*1)

Build Status Latest Stable Version Total Downloads Scrutinizer Quality Score Code Coverage, (*2)

Install

Via Composer, (*3)

``` bash $ composer require arrounded/queues, (*4)


A Laravel 4.2 version also availabe: `composer require arrounded/queues:dev-laravel/4.2` ## Usage First add the module's service provider and facade to config/app.php: ```php Arrounded\Queues\ServiceProvider::class
'Queues' => Arrounded\Queues\Facades\Queues::class,

Now you can start using the helper in your application code via the Facade:, (*5)

Pushing jobs

Queues::on('foo')->uses(Foobar::class)->push()

This will push a job on the local_foo_normal queue., (*6)

Priorities, (*7)

Queues::on('foo')->uses(Foobar::class)->priority(Queues::PRIORITY_HIGH)->push();

This will push a job on the local_foo_high queue., (*8)

Passing a payload, (*9)

Queues::on('foo')->uses(Foobar::class)->with([
    'bar' => 'foo'
])->push();

This will push a job on the local_foo_normal queue with a {'bar': 'foo'} payload, (*10)

Delaying execution, (*11)

Queues::on('foo')->uses(Foobar::class)->delay(10)->push();

This will delay the execution of the job by 10 seconds., (*12)

Prefixing queue names

The default behavior is to prefix all queues with the current app environment. If you want to overwrite this default on an application level, you can do it in your own ServiceProvider:, (*13)

$this->app['queues']->setPrefix('foobar') // foobar_foo_normal

Disabling queueing, (*14)

In some cases you might want to disable queueing all together (for example during integration/functional tests), (*15)

// To disable
$this->app['queues']->disabled()

// To re-enable
$this->app['queues']->disabled(false)

Dependency Injection

You can also use dependency injection:, (*16)

use Arrounded\Queues\Queues;

class FooService
{
    public function __construct(Queues $queues)
    {
        $this->queues = $queues;
    }

Testing

bash $ composer test, (*17)

License

The MIT License (MIT). Please see License File for more information., (*18)

The Versions