envoylope / event-loop
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=8.1
- asmblah/php-amqp-compat: ^0.4
- react/event-loop: ^1.4
Requires (Dev)
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.10
- phpstan/phpstan-mockery: ^1.1
- phpunit/phpunit: ^10.2
- tasque/event-loop: ^0.1
- tasque/tasque: ^0.1
README
Transmits AMQP heartbeats for Envoylope using a ReactPHP EventLoop.
Usage
Install with Composer:
$ composer require envoylope/event-loop
(Optionally) install Tasque and Tasque EventLoop
If you are running a traditional PHP application, a ReactPHP EventLoop may regularly be blocked by synchronous logic/IO. This can be mitigated somewhat by Tasque EventLoop, which implements green threads for PHP.
See the respective usage instructions linked above for configuring the Tasque/EventLoop Nytris packages.
Configuring platform boot config
Once the PHP AMQP-Compat Nytris package is configured, this scheduler will be used:
nytris.config.php
<?php declare(strict_types=1); use Asmblah\PhpAmqpCompat\AmqpCompatPackage; use Asmblah\PhpCodeShift\Cache\Layer\FilesystemCacheLayerFactory; use Asmblah\PhpCodeShift\ShiftPackage; use Envoylope\EventLoop\EventLoopSchedulerFactory; use Nytris\Boot\BootConfig; use Nytris\Boot\PlatformConfig; use Tasque\Core\Scheduler\ContextSwitch\TimeSliceStrategy; use Tasque\EventLoop\TasqueEventLoopPackage; use Tasque\TasquePackage; $bootConfig = new BootConfig(new PlatformConfig(__DIR__ . '/var/cache/nytris')); $bootConfig->installPackage(new AmqpCompatPackage( // Install the scheduler. schedulerFactory: new EventLoopSchedulerFactory() )); $bootConfig->installPackage(new ShiftPackage( cacheLayerFactory: new FilesystemCacheLayerFactory(), relativeSourcePaths: ['src', 'vendor'] )); $bootConfig->installPackage(new TasquePackage( new TimeSliceStrategy(timeSliceCheckIntervalTocks: 100) )); $bootConfig->installPackage(new TasqueEventLoopPackage()); return $bootConfig;