tarantool/jobbuilder

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

Fund package maintenance!
rybakit

v0.3.2 2022-10-11 19:10 UTC

This package is auto-updated.

Last update: 2024-10-11 23:43:34 UTC


README

Quality Assurance Telegram

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)
    ->withRecurrenceIntervalSeconds(600)
    ->withTimeToLiveSeconds(300)
    ->withTimeToRunSeconds(180)
    ->withPriority(4)
    ->withDelaySeconds(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.