arrounded/queues

This package is abandoned and no longer maintained. No replacement package was suggested.

A set of queue helpers

1.0.2 2015-09-15 18:57 UTC

This package is auto-updated.

Last update: 2019-11-15 14:49:10 UTC


README

An optionated helper for dealing with queues

Build Status Latest Stable Version Total Downloads Scrutinizer Quality Score Code Coverage

Install

Via Composer

$ composer require arrounded/queues

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:

Arrounded\Queues\ServiceProvider::class
'Queues' => Arrounded\Queues\Facades\Queues::class,

Now you can start using the helper in your application code via the Facade:

Pushing jobs

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

This will push a job on the local_foo_normal queue.

Priorities

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

This will push a job on the local_foo_high queue.

Passing a payload

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

Delaying execution

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

This will delay the execution of the job by 10 seconds.

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:

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

Disabling queueing

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

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

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

Dependency Injection

You can also use dependency injection:

use Arrounded\Queues\Queues;

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

Testing

$ composer test

License

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