efabrica / hermes-extension
Extension for tomaj/hermes
Installs: 38 743
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: ^7.4 | ^8.0
- ext-json: *
- lulco/redis-proxy: ~0.5 | ^1.0
- symfony/console: ^5.4 | ^6.0 | ^7.0
- tomaj/hermes: ^4.0
This package is auto-updated.
Last update: 2024-11-29 20:03:19 UTC
README
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