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)
composer require efabrica/hermes-extension
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