mleczakm / swoole-bundle-scheduler
Run Symfony Scheduler inside a Swoole HTTP worker with adaptive one-shot timers.
Package info
github.com/mleczakm/swoole-bundle-scheduler
Type:symfony-bundle
pkg:composer/mleczakm/swoole-bundle-scheduler
Requires
- php: ^8.3
- ext-swoole: *
- psr/cache: ^2.0 || ^3.0
- psr/clock: ^1.0
- psr/event-dispatcher: ^1.0
- psr/log: ^3.0
- swoole-bundle/swoole-bundle: >0.33 <1.0
- symfony/cache: >=7.4 <9.0
- symfony/clock: >=7.4 <9.0
- symfony/config: >=7.4 <9.0
- symfony/dependency-injection: >=7.4 <9.0
- symfony/event-dispatcher: >=7.4 <9.0
- symfony/http-kernel: >=7.4 <9.0
- symfony/messenger: >=7.4 <9.0
- symfony/scheduler: >=7.4 <9.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- macpaw/symfony-health-check-bundle: ^2.1
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^11.5 || ^12.5
- symfony/framework-bundle: >=7.4 <9.0
- symfony/lock: >=7.4 <9.0
Suggests
- macpaw/symfony-health-check-bundle: Enables the /health scheduler heartbeat check (swoole_bundle_scheduler.health_check)
Provides
None
Conflicts
None
Replaces
None
README
Run Symfony Scheduler inside worker #0 of a Swoole HTTP server, without a separate Messenger consumer. Requires PHP 8.3+, ext-swoole, Symfony 7.4/8.x and swoole-bundle with coroutines enabled.
Register SwooleBundle\Scheduler\SwooleBundleSchedulerBundle in config/bundles.php,
then configure:
swoole_bundle_scheduler: enabled: true interval: 60
Normal #[AsSchedule] providers are discovered automatically. Messages use the normal
Messenger bus routing; route expensive work to task workers or another async transport.
The loop starts after fork in worker #0. One-shot timers wake at the next due date,
bounded by interval. Pooled services are released after each pass. Exceptions are
logged and retried. Shared-memory ownership prevents concurrent passes during worker
reload; the heartbeat uses shared memory instead of database writes.
Version 0.3 is a breaking change from 0.2. See the migration notes before upgrading.