pyrowman/pheanstalk-bundle

PheanstalkBundle 是一个 Symfony2 扩展包,提供用于管理 evqueue 工作队列服务器和 pheanstalk 集成的命令行界面。

安装: 3

依赖: 0

建议: 0

安全: 0

星星: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

1.0.0 2019-11-29 11:32 UTC

This package is auto-updated.

Last update: 2024-09-29 05:08:59 UTC


README

Packagist Version Scrutinizer Code Quality Code Coverage Build Status

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

贡献者