christoph-kluge/bref-sqs-laravel
Composer 安装命令:
composer require christoph-kluge/bref-sqs-laravel
包简介
Serverless Queues for Laravel on AWS Lambda (SQS)
README 文档
README
Do you have scaling problems with your laravel queues? Install, deploy and bother less!
Thanks to the severless approach it's very easy to scale parts of your software. This projects adds native laravel queue support.
Thanks to brefphp/bref and serverless/serverless which do the heavy lifing here.
Supported bref versions
| Version | Tag | Status |
|---|---|---|
| >=1.3 | ^2.0 | supported |
| 1.2.x | ^1.0 | supported |
| 1.1.x | ^0 | untested - perhaps supported |
| 0.5.x | 0.0.1 | supported |
Supported laravel versions
| Laravel Version | Tag | Status |
|---|---|---|
| 9.x | ^2.0 | supported |
| 8.x | ^1.0 and ^2.0 | supported |
| 7.x | 0.* | supported |
| 6.x | 0.* | supported |
| 5.8 | 0.* | supported |
| < 5.8 | - | unknown |
Install
To install via Composer, use the command below. It will automatically detect the latest version and bind it with ^.
composer require christoph-kluge/bref-sqs-laravel
This package will automatically register the ServiceProvider within your laravel application.
Usage instructions
- Configure your application to use SQS queues (please refer to the official laravel documentation)
- Install this package through composer
- Add the example
artisan.phpto the root directory of your project - Update your
serverless.ymlwith a new handler using theartisan.php
Example artisan.php
#!/opt/bin/php <?php declare(strict_types=1); $appRoot = getenv('LAMBDA_TASK_ROOT'); require_once $appRoot . '/vendor/autoload.php'; require_once $appRoot . '/bootstrap/app.php'; /** @var \Illuminate\Contracts\Console\Kernel $kernel */ $kernel = app(\Illuminate\Contracts\Console\Kernel::class); $kernel->bootstrap(); $status = $kernel->handle( $input = new Symfony\Component\Console\Input\StringInput(getenv('ARTISAN_COMMAND')), new Symfony\Component\Console\Output\ConsoleOutput ); $kernel->terminate($input, $status);
Example serverless.yml
functions: queue: handler: artisan.php environment: ARTISAN_COMMAND: 'sqs:work sqs --tries=3 --sleep=1 --delay=1' layers: - ${bref:layer.php-81} events: - sqs: arn: arn:aws:sqs:region:XXXXXX:default-queue batchSize: 10 another-queue: handler: artisan.php environment: ARTISAN_COMMAND: 'sqs:work sqs --queue=another-queue --tries=3 --sleep=1 --delay=1' layers: - ${bref:layer.php-81} events: - sqs: arn: arn:aws:sqs:region:XXXXXX:another-queue batchSize: 10
TODOs
- Test FIFO queues
- Partial failures should not "re-send" new messages, instead we should delete successful messages and throw an exception if at least 1 job failed inside the batchsize
- (In case the above point will work - this becames obsolete) Dead-Letter-Queue support (native by reading the AWS settings or custom?)
References / Links / Insights
Useful links and insights about this topic:
christoph-kluge/bref-sqs-laravel 适用场景与选型建议
christoph-kluge/bref-sqs-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65.06k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2020 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 christoph-kluge/bref-sqs-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 christoph-kluge/bref-sqs-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 65.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-13