2017 © Pedro Peláez
 

library message-bus-sf-process

image

webit/message-bus-sf-process

  • Wednesday, January 3, 2018
  • by dbojdo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 22 % Grown

The README.md

Message Bus - Symfony Process Infrastructure

Symfony Process infrastructure for Message Bus, (*1)

Installation

composer require webit/message-bus-sf-process=^1.0.0

Usage

ProcessFactory

To use both ProcessPublisher or ProcessConsumer instance of ProcessFactory is needed., (*2)

use Webit\MessageBus\Message;
use Symfony\Component\Process\Process;

class MyProcessFactory implements ProcessFactory
{
    /**
     * @inheritdoc
     */
    public function create(Message $message)
    {
        return new Process(
            sprintf(
                '/usr/local/my-binary.php %s %s',
                escapeshellarg($message->type()),
                escapeshellarg($message->content())
            )
        );
    }
}

Synchronous ProcessLauncher

To run process synchronously use SynchronousProcessLauncher, (*3)

use Webit\MessageBus\Infrastructure\Symfony\Process\Launcher\SynchronousProcessLauncher;

$myFactory = new MyProcessFactory();
$launcher = new SynchronousProcessLauncher($myFactory);

Asynchronous ProcessLauncher

To run process asynchronously use AsynchronousProcessLauncher, (*4)

use Webit\MessageBus\Infrastructure\Symfony\Process\Launcher\ParallelProcessManager;
use Webit\MessageBus\Infrastructure\Symfony\Process\Launcher\AsynchronousProcessLauncher;

$myFactory = new MyProcessFactory();
$launcher = new AsynchronousProcessLauncher(
    $myFactory,
    new ParallelProcessManager($maxParallelProcessNumber = 5) // to run at most 5 parallel processes
);

Publisher integration

Configured ProcessLauncher can be used with ProcessPublisher, (*5)

use Webit\MessageBus\Infrastructure\Symfony\Process\ProcessPublisher;
use Webit\MessageBus\Message;

$publisher = new ProcessPublisher($launcher);
$publisher->publish(new Message('type', 'content'));

Consumer integration

Configured ProcessLauncher can be used with ProcessConsumer, (*6)

use Webit\MessageBus\Infrastructure\Symfony\Process\ProcessConsumer;
use Webit\MessageBus\Message;

$consumer = new ProcessConsumer($launcher);
$consumer->consume(new Message('type', 'content'));

Running tests

Install dependencies with composer, (*7)

docker-compose run --rm composer
docker-compose run --rm spec

The Versions

03/01 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

command symfony process message queue message bus

03/01 2018

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

command symfony process message queue message bus

03/01 2018

dev-develop

dev-develop

  Sources   Download

MIT

The Requires

 

The Development Requires

command symfony process message queue message bus