2017 © Pedro Peláez
 

library laravel-gearman-rpc

Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman

image

gitkv/laravel-gearman-rpc

Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman

  • Monday, May 7, 2018
  • by gitkv
  • Repository
  • 1 Watchers
  • 3 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 50 % Grown

The README.md

Laravel Gearman rpc

Build Status, (*1)

Laraval / Lumen Gearman Remote Procedure Call, (*2)

Requires: * Laravel / Lumen >=5.5 * PHP >= 7.1 * Gearman PHP extension * Socket PHP extension, (*3)

Installation

  • Run:
composer require "gitkv/laravel-gearman-rpc"
  • Install gearman job server as PHP-extension: http://gearman.org/getting-started/#gearman_php_extension
  • Install supervisor:
apt-get install supervisor

Configuration

Laravel:

Add service provider to /config/app.php:, (*4)

'providers' => [
    gitkv\GearmanRpc\GearmanRpcServiceProvider::class
],
'aliases' => [
    'GearmanRpc' => gitkv\GearmanRpc\Facade\GearmanRpc::class,
],

Publish config/gearman-rpc.php, (*5)

php artisan vendor:publish --provider="gitkv\GearmanRpc\GearmanRpcServiceProvider" --tag=config

Usage

Worker:

Create handler:

Create a file in the directory app\Rpc\MyRpcHandler.php, (*6)

<?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, (*7)

'MyExampleFunction' => \App\Rpc\MyRpcHandler::class,

Configure supervisor

Example supervisor config, (*8)

[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

Client:

Synch call, (*9)

<?php
$result = GearmanRpc::doNormal('MyExampleFunction', json_encode(['test'=>'data']));

Asynch call, (*10)

<?php
GearmanRpc::doBackground('MyExampleFunction', json_encode(['test'=>'data']));

The Versions

07/05 2018

dev-master

9999999-dev https://github.com/gitkv/laravel-gearman-rpc#readme

Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen server job supervisor rpc gearman workers

07/05 2018

dev-dev

dev-dev https://github.com/gitkv/laravel-gearman-rpc#readme

Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen server job supervisor rpc gearman workers

07/05 2018

v0.1

0.1.0.0 https://github.com/gitkv/laravel-gearman-rpc#readme

Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen server job supervisor rpc gearman workers

04/05 2018

v0.1-alpha

0.1.0.0-alpha https://github.com/gitkv/laravel-gearman-rpc#readme

Laravel/Lumen Gearman rpc. Based from https://github.com/mhlavac/gearman

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen server job supervisor rpc gearman workers