glorpen/queue-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

glorpen/queue-bundle

Composer 安装命令:

composer require glorpen/queue-bundle

包简介

Task queue

README 文档

README

Note: the repository is not maintained anymore.

Bundle for offloading work to server side. Can add service tasks/jobs to queue for later execution.

Queue runs can safely overlap since tasks are locked upon acquiring by runner.

For forking and other funnies:

Installation

  • add requirements to composer.json:
{
    "require": {
        "glorpen/queue-bundle": "*"
    }
}
  • enable the bundle in your AppKernel class

app/AppKernel.php

<?php

class AppKernel extends AppKernel
{
   public function registerBundles()
   {
       $bundles = array(
           ...
           new Glorpen\QueueBundle\GlorpenQueueBundle(),
           ...
       );
   }
}
  • choose backend in config.yml

Backends

Propel

Bundle configuration:

glorpen_queue:
    backend: propel

Usage

To add new task:

<?php
$queue = $container->get("glorpen.queue");
$queue->create('my.tasks_container', 'myMethod', array("arg1", 2));

Then to execute use app/console queue:run:

Starting task test:method
Task 1:test:method ended after 0 seconds with status "failed"

Remember that:

  • dataset is fetched on task execution, so it can change after you create task.
  • task arguments are serialized and stored in choosen backend

Other useful commands:

  • queue:restart-failed simply marks failed tasks as pending
  • queue:update marks crashed (eg. on OOM) tasks as failed and removes succesfull tasks

Named tasks

To add new named task:

<?php
$queue = $container->get("glorpen.queue");
$queue->create('my.tasks_container', 'myMethod', array("arg1", 2), 'now', 'my_named_task');

Then you can retrieve it with:

<?php
$queue = $container->get("glorpen.queue");
$task = $queue->getTask('my_named_task');
echo $task->getStatus();
echo $task->getProgress();

When creating named task:

  • completed or not started task with same name will be removed
  • if old task is currently running an exception will be thrown

Metadata

Inside executing task you can set its current progress:

<?php
$queue = $container->get("glorpen.queue");
$queue->setCurrentTaskProgress(50);

统计信息

  • 总下载量: 1.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2013-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固