sshilko / backq
使用队列、工作者和发布者进行后台任务处理
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
后台 队列处理 - 发布任务并由工作者简化处理
- 发送 APNS 推送通知(旧版API)
- 向 Android 发送 FCM 推送通知(GCM/FCM)
- 通过 AWS SNS arn 发送 AWS SNS 推送通知
- 通过 Guzzle 异步执行 Psr7\Request
- 使用 symfony/process 执行任何进程
- 通过 DynamoSQS 适配器和序列化工作者实现 长延迟调度,以实现可靠的长周期计划任务
- 可扩展 - 编写您自己的工作者并直接使用现有的适配器...
安装
#composer self-update && composer clear-cache && composer diagnose
composer require sshilko/backq:^3.0
使用 Redis 适配器和 process
工作者示例
#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
支持的队列服务器
功能
工作者与适配器的兼容性
适配器实现的功能
工作者可用的功能
setRestartThreshold
(限制最大工作周期数,然后终止)setIdleTimeout
(限制最大空闲时间,然后终止)
TLDR
查看 /example 文件夹以获取使用示例
旧版本 1 的详细评估
许可证
MIT
版权所有 2013-2022 Sergei Shilko 版权所有 2016-2019 Carolina Alarcon