2017 © Pedro Peláez
 

library yii2-gearman

Consumer for gearman server

image

perspectivain/yii2-gearman

Consumer for gearman server

  • Saturday, March 21, 2015
  • by jsopra
  • Repository
  • 6 Watchers
  • 0 Stars
  • 273 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 Gearman

Component for use gearman server as consumer jobs, (*1)

Deprecated if Yii2 Queue Component (https://github.com/yiisoft/yii2/issues/492) was accepted, (*2)

Simple Usage

Register a component, (*3)

'components' => [
    'gearman' => [
        'class' => 'perspectivain\gearman\Gearman',
        'jobsNamespace' => '\app\jobs\\',
        'servers' => [
            ['host' => GEARMAN_SERVER_HOST, 'port' => GEARMAN_SERVER_PORT],
        ],
    ],
    ...
],

Register a command controller, (*4)

'controllerMap' => [
    'worker' => [
        'class' => 'perspectivain\gearman\WorkerController'
    ],
    ...
]

Create an job class, (*5)

namespace app\jobs;

class MyJob implements perspectivain\gearman\InterfaceJob
{
    /**
     * @inheritdoc
     */
    public function run($attributes)
    {
        //do something
    }
}

Register an job in your application, (*6)

\perspectivain\gearman\BackgroundJob::register('GearmanJob', ['attributeA' => 10]);

Run the worker, (*7)

# php yii worker/run-one

If your need continuous worker, use the crontab or the supervisor process control system (http://supervisord.org/)., (*8)

Multi queue Usage

Register an job in your application, (*9)

$queueName = 'newqueue';
\perspectivain\gearman\BackgroundJob::register('GearmanJob', ['attributeA' => 10], \perspectivain\gearman\BackgroundJob::NORMAL, $queueName);

Run the worker, (*10)

# php yii worker/run-one newqueue

Installing

The preferred way to install this extension is through composer., (*11)

{
  "require": {
    "perspectivain/yii2-gearman": "*"
  }
}

The Versions

21/03 2015

dev-master

9999999-dev https://github.com/perspectivain/yii2-gearman

Consumer for gearman server

  Sources   Download

MIT

The Requires

 

by Juliano Baggio di Sopra

php yii2 gearman