2017 © Pedro Peláez
 

library jobqueue

Job Queue implementation.

image

phlib/jobqueue

Job Queue implementation.

  • Wednesday, July 4, 2018
  • by letssurf
  • Repository
  • 6 Watchers
  • 2 Stars
  • 297 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 10 Versions
  • 15 % Grown

The README.md

phlib/jobqueue

Code Checks Codecov Latest Stable Version Total Downloads Licence, (*1)

Job Queue implementation., (*2)

Install

Via Composer, (*3)

``` bash $ composer require phlib/jobqueue, (*4)

or
``` JSON
"require": {
    "phlib/jobqueue": "*"
}

Basic Usage

Bootstrap ``` php $beanstalk = (new \Phlib\Beanstalk\Factory())->create('localhost'); $db = new \Phlib\Db\Adapter(['host' => '127.0.0.1', 'dbname' => 'example']);, (*5)

$scheduler = new \Phlib\JobQueue\DbScheduler($db, 300, 600); $jobQueue = new \Phlib\JobQueue\Beanstalk\Scheduled($beanstalk, $scheduler);, (*6)


Producer ``` php $delay = strtotime('+1 week') - time(); $jobQueue->put('my-queue', ['my' => 'jobData'], ['delay' => $delay]);

Consumer ``` php do { while ($job = $jobQueue->retrieve($queue)) { echo "Found new job {$job->getId()}\n", var_export($job->getBody(), true), "\n"; $jobQueue->markAsComplete($job); }, (*7)

usleep(500);

} while (true);, (*8)


## Jobqueue Script The script has a dependency on two constructed objects. The Job Queue interface and the Scheduler interface. In order to provide this the following describes how they are injected into the script. jobqueue-config.php (can be located in the root or ```config``` folder. ``` php <?php $app = new MyApp(); return new \Phlib\JobQueue\Console\MonitorDependencies($app['jobqueue'], $app['scheduler']);

Table Schema

SQL CREATE TABLE `scheduled_queue` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `tube` varchar(255) NOT NULL DEFAULT 'default', `data` blob NOT NULL, `scheduled_ts` timestamp NULL DEFAULT NULL, `priority` smallint(5) unsigned DEFAULT NULL, `ttr` smallint(5) unsigned DEFAULT NULL, `picked_by` varchar(20) DEFAULT NULL, `picked_ts` timestamp NULL DEFAULT NULL, `create_ts` timestamp NOT NULL, `update_ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `scheduled_ts` (`scheduled_ts`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;, (*9)

License

This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version., (*10)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details., (*11)

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/., (*12)

The Versions

04/07 2018

dev-master

9999999-dev

Job Queue implementation.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

04/07 2018

dev-issue-2-invalid-type-hint

dev-issue-2-invalid-type-hint

Job Queue implementation.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

20/06 2018

1.1.0

1.1.0.0

Job Queue implementation.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

13/06 2017

1.0.1

1.0.1.0

Job Queue implementation.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

23/02 2017

1.0.0

1.0.0.0

Job Queue implementation.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

03/01 2017

0.0.5

0.0.5.0

Job Queue implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

03/11 2016

0.0.4

0.0.4.0

Job Queue implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

06/06 2016

0.0.3

0.0.3.0

Job Queue implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

25/04 2016

0.0.2

0.0.2.0

Job Queue implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job

25/04 2016

0.0.1

0.0.1.0

Job Queue implementation.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Luke Richards

task queue beanstalk job