tarantool/jobbuilder

A set of utility classes to help creating complex jobs for Tarantool JobQueue.

v0.1.0 2019-03-20 20:33 UTC

README

A set of utility classes to help creating complex jobs for Tarantool JobQueue.

Installation

The recommended way to create a new application is through Composer:

composer require tarantool/jobbuilder

Usage

use Tarantool\JobQueue\JobBuilder\JobBuilder;

...

$task = JobBuilder::fromService('service_foo', ['bar', 'baz'])
    ->withServiceMethod('qux')
    ->withConstantBackoff()
    ->withMaxRetries(3)
    ->withRecurrenceInterval(60)
    ->withTimeToExecute(5)
    ->withTimeToRun(300)
    ->withPriority(4)
    ->withDelay(60)
    ->withTube('foobar')
    ->putTo($queue);
use App\Job\MyJob\MyJobHandler;
use Tarantool\JobQueue\JobBuilder\JobBuilder;
use Tarantool\JobQueue\JobBuilder\JobEmitter;

...

$jobBuilders = (static function () use ($ids) {
    foreach ($ids as $id) {
        yield JobBuilder::fromService(MyJobHandler::class, ['id' => $id]);
    }
})();

(new JobEmitter())->emit($jobBuilders, $queue);

Tests

vendor/bin/phpunit

License

The library is released under the MIT License. See the bundled LICENSE file for details.