pyrowman / pheanstalk-bundle
PheanstalkBundle 是一个 Symfony2 扩展包,提供用于管理 evqueue 工作队列服务器和 pheanstalk 集成的命令行界面。
1.0.0
2019-11-29 11:32 UTC
Requires
- php: >=7.1
- psr/log: ~1.0
- pyrowman/pheanstalk: ~1.0
- symfony/console: ~2.5|~3.0|^4.0
- symfony/framework-bundle: ~2.5|~3.0|^4.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-29 05:08:59 UTC
README
Symfony3 的 EvQueue 工作队列客户端。
Pyrowman\PheanstalkBundle 是从 LeezyPheanstalkBundle 分支出来的。
Pyrowman\PheanstalkBundle 是一个 Symfony3 扩展包,提供了以下功能的 pheanstalk 集成:
- 用于管理队列的命令行界面。
- Symfony3 事件系统的集成。
- Symfony3 性能分析系统的集成,以监控您的 evqueue 服务器。
- Symfony3 日志系统的集成。
- 用于自定义命令功能的代理系统。
- 自动注入:
PheanstalkInterface
文档
使用示例
<?php namespace Acme\DemoBundle\Controller; use Pheanstalk\Structure\Schedule; use Pheanstalk\Structure\TimeSchedule; use Pyrowman\PheanstalkBundle\Proxy\PheanstalkProxy; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\DependencyInjection\ContainerInterface; class HomeController extends AbstractController { public function indexAction() { $sc = $this->get('service_container'); /** @var PheanstalkProxy $pheanstalk */ $pheanstalk = $sc->get("pheanstalk"); // Create a simple Worflow with one task inside $workflow = $pheanstalk->createTask('Sleep', 'Test', '/bin/sleep 80'); // Put the job into instance execution $pheanstalk->put($workflow); // ---------------------------------------- // check server availability $pheanstalk->getConnection()->isServiceListening(); // true or false //----------------------------------------- // Add a scheduler for the job (by default in continous) $schedule = new Schedule($workflow->getId(), new TimeSchedule()); $workflowSchedule = $pheanstalk->createSchedule($schedule); //----------------------------------------- // Edit a workflow $workflow->setGroup('2nd test group'); $pheanstalk->update($workflow); //----------------------------------------- // Getting infos on the execution of a workflow $workflowInstances = $pheanstalk->getWorkflowInstances($workflow); //----------------------------------------- // Delete a job if ($workflow = $pheanstalk->workflowExists('Sleep')) $pheanstalk->delete($workflow); } public static function getSubscribedServices() { return array_merge(parent::getSubscribedServices(), [ // ... 'service_container' => ContainerInterface::class, ]); } } ?>
测试
# ensure you have Composer set up $ wget https://getcomposer.org.cn/composer.phar $ php composer.phar install $ bin/phpunit PHPUnit 7.1.2 by Sebastian Bergmann and contributors. .......................................................... 58 / 58 (100%) Time: 11.36 seconds, Memory: 16.00 MB OK (58 tests, 98 assertions) Generating code coverage report in HTML format ... done
许可
本扩展包采用 MIT 许可证。请参阅完整的许可协议。
致谢
作者 - Valentin Corre
原始库作者 - Thomas Tourlourat
贡献者
- Peter Kruithof : 版本 3
- Maxwell2022 : Symfony2 性能分析集成