dev-master
9999999-dev https://github.com/perspectivain/yii2-gearmanConsumer for gearman server
MIT
The Requires
by Juliano Baggio di Sopra
php yii2 gearman
Consumer for gearman server
Component for use gearman server as consumer jobs, (*1)
Deprecated if Yii2 Queue Component (https://github.com/yiisoft/yii2/issues/492) was accepted, (*2)
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)
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
The preferred way to install this extension is through composer., (*11)
{ "require": { "perspectivain/yii2-gearman": "*" } }
Consumer for gearman server
MIT
php yii2 gearman