sshilko / backq
Background jobs processing with queue, workers & publishers
3.0.2
2022-01-12 12:12 UTC
Requires
- php: >=7.2
- ext-redis: *
- aws/aws-sdk-php: ^3.133
- davidpersson/beanstalk: ^2.0
- duccio/apns-php: =1.0.1
- illuminate/queue: >=5
- illuminate/redis: >=5
- opis/closure: ^3.6
- psr/log: ^1.1
- symfony/process: >=4
README
Background queue processing - publish tasks and process with workers, simplified.
- Sending APNS push notifications (Legacy API)
- Sending FCM push notifications to Android (GCM/FCM)
- Sending AWS SNS push notifications via AWS SNS arn's
- Executing Psr7\Request asynchronously via Guzzle
- Executing any processes with symfony/process
- Long delay scheduling via DynamoSQS Adapter and Serialized worker, for reliable long-term scheduled jobs
- Extendable - write your own worker and use existing adapters out of the box ...
Installation
#composer self-update && composer clear-cache && composer diagnose
composer require sshilko/backq:^3.0
Example with Redis adapter and process
worker
#launch local redis
docker run -d --name=example-backq-redis --network=host redis
#install library in any folder for testing
mkdir /tmp/example && cd /tmp/example
composer require sshilko/backq:^3.0
#post job to queue (schedule)
cd vendor/sshilko/backq/example/publishers/process && php redis.php && cd /tmp/example
#[debug] connect
#[debug] _connect
#[debug] putTask
#[debug] putTask is connected and ready to: write
#[debug] putTask pushed task without delay xoOgPKcS9bIDVXSaLYH9aLB22gzzptRo
#[debug] putTask return 'xoOgPKcS9bIDVXSaLYH9aLB22gzzptRo'
#Published process message via redis adapter as ID=xoOgPKcS9bIDVXSaLYH9aLB22gzzptRo
#fetch job from queue (work)
cd vendor/sshilko/backq/example/workers/process && php redis.php && cd /tmp/example
#[debug] connect
#[debug] _connect
#[debug] pickTask
#[debug] pickTask blocking for 5 seconds until get a job
#[debug] pickTask reserved a job nOgykJV81g969yw2wRMF94V9KiIeKN4P
#[debug] afterWorkSuccess
#[debug] afterWorkSuccess currently 1 reserved job(s)
#[debug] afterWorkSuccess releasing completed nOgykJV81g969yw2wRMF94V9KiIeKN4P job
#[debug] Disconnecting
#[debug] Disconnecting, previously connected
#[debug] Disconnecting, state detected
#[debug] Disconnecting, state detected, queue is connected
#[debug] Disconnecting, state 0 jobs reserved and not finalized
#[debug] Disconnecting, state detected, disconnecting queue manager
#[debug] Disconnecting, successful
#verify job executed (example process worker does echo $( date +%s ) >> /tmp/test)
cat /tmp/test
docker stop example-backq-redis
Supported queue servers
Features
Workers compatibility with adapters
Adapter implemented features
Worker available features
setRestartThreshold
(limit max number of jobs cycles, then terminate)setIdleTimeout
(limit max idle time, then terminating)
TLDR
See /example folder for usage examples
Old version 1 detailed review
Blog post about sending Apple push notifications
Licence
MIT
Copyright 2013-2022 Sergei Shilko Copyright 2016-2019 Carolina Alarcon