Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 2.17 KB

README.md

File metadata and controls

65 lines (50 loc) · 2.17 KB

Hermes extension

PHPStan level PHP static analysis Latest Stable Version Total Downloads

Extension for tomaj/hermes. It contains:

  • HermesWorker (symfony command)
  • Drivers:
    • RedisProxySetDriver (driver implementation using RedisProxy)
    • RedisProxySortedSetDriver
    • DummyDriver (for testing purposes)
  • Heartbeat functionality with drivers
    • RedisProxyStorage
    • MemoryStorage (for testing purposes)

Installation

composer require efabrica/hermes-extension

Setup

use Efabrica\HermesExtension\Driver\RedisProxySetDriver;
use Efabrica\HermesExtension\Heartbeat\RedisProxyStorage;
use RedisProxy\RedisProxy;
use Tomaj\Hermes\Dispatcher;
use Tomaj\Hermes\Handler\EchoHandler;
use Tomaj\Hermes\Shutdown\SharedFileShutdown;

$redisProxy = new RedisProxy(/*...*/);

// Register driver
$driver = new RedisProxySetDriver($redisProxy, 'hermes');

// Optionally register shutdown and / or heartbeat
$driver->setShutdown(new SharedFileShutdown('/tmp/hermes_shared_file'));
$driver->setHeartbeat(new RedisProxyStorage($redisProxy, 'hermes_heartbeat'));

// Create Dispatcher
$dispatcher = new Dispatcher($driver);

// Register handlers
$dispatcher->registerHandler('event_type', new EchoHandler());

Register hermes worker to symfony console application:

// file: bin/command

use Efabrica\HermesExtension\Command\HermesWorker;
use Symfony\Component\Console\Application;


$application = new Application();
$application->add(new HermesWorker($dispatcher));
$application->run();

Run command:

php bin/command hermes:worker