Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman
gitkv/laravel-gearman-rpc is a Laravel package for laravel/lumen gearman rpc. based from https://github.com/mhlavac/gearman.
It currently has 7 GitHub stars and 66 downloads on Packagist (latest version v0.1).
Install it with composer require gitkv/laravel-gearman-rpc.
Discover more Laravel packages by gitkv
or browse all Laravel packages to compare alternatives.
Last updated
Laraval / Lumen Gearman Remote Procedure Call
Requires:
composer require "gitkv/laravel-gearman-rpc"
apt-get install supervisor
Add service provider to /config/app.php:
'providers' => [
gitkv\GearmanRpc\GearmanRpcServiceProvider::class
],
'aliases' => [
'GearmanRpc' => gitkv\GearmanRpc\Facade\GearmanRpc::class,
],
Publish config/gearman-rpc.php
php artisan vendor:publish --provider="gitkv\GearmanRpc\GearmanRpcServiceProvider" --tag=config
Create a file in the directory app\Rpc\MyRpcHandler.php
<?php
namespace App\Rpc;
use gitkv\GearmanRpc\HandlerContract;
class MyRpcHandler implements HandlerContract {
public function handle($payload) {
return [
'status' => 'success',
'payload' => $payload,
];
}
}
Add your handler to the handlers section in the config/gearman-rpc.php file
'MyExampleFunction' => \App\Rpc\MyRpcHandler::class,
Example supervisor config
[program:app-rpc-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan gearman-rpc
autostart=true
autorestart=true
user = www
numprocs=1
redirect_stderr=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
Synch call
<?php
$result = GearmanRpc::doNormal('MyExampleFunction', json_encode(['test'=>'data']));
Asynch call
<?php
GearmanRpc::doBackground('MyExampleFunction', json_encode(['test'=>'data']));