long-running/core
Composer 安装命令:
composer require long-running/core
包简介
Tools for working with long-running processes
README 文档
README
This is a read only split from the LongRunning mono repository.
If you want to make changes, please create a pull request there.
Installation
composer require long-running/core
Symfony
If you are using Symfony, make sure to enable the bundle:
<?php // config/bundles.php return [ // ... LongRunning\Core\Bundle\LongRunningBundle::class => ['all' => true], ];
How to use?
<?php final class MyCleaner implements \LongRunning\Core\Cleaner { public function cleanUp() : void { echo "Cleaning up memory!"; } } $cleaner = new \LongRunning\Core\DelegatingCleaner([ new MyCleaner(), ]); while (true) { // Do heavy work, like processing jobs from a queue echo "Doing heavy work"; sleep(1); echo "Done with heavy work"; // Cleanup things $cleaner->cleanUp(); }
If you are using Symfony, any service that implements the LongRunning\Core\Cleaner interface
will be autoconfigured and added to the LongRunning\Core\DelegatingCleaner.
The LongRunning\Core\DelegatingCleaner is aliased to LongRunning\Core\Cleaner.
That means that you can inject the LongRunning\Core\Cleaner service in your worker and it will
call all configured cleaners on cleanUp():
<?php namespace App; use LongRunning\Core\Cleaner; final class Worker { private Cleaner $cleaner; public function __construct(Cleaner $cleaner) { $this->cleaner = $cleaner; } public function doWork() : void { while (true) { // Do heavy work, like processing jobs from a queue echo "Doing heavy work"; sleep(1); echo "Done with heavy work"; // Cleanup things $this->cleaner->cleanUp(); } } }
Existing cleaners
LongRunning provides 2 packages that add additional cleaners:
long-running/core 适用场景与选型建议
long-running/core 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 683.25k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 long-running/core 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 long-running/core 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 683.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-01