dubture/async-bundle 问题修复 & 功能扩展

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

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

dubture/async-bundle

最新稳定版本:0.0.1

Composer 安装命令:

composer require dubture/async-bundle

包简介

Provides an easy to use abstraction for async backend workers in Symfony2

README 文档

README

Build Status Scrutinizer Code Quality

This Symfony bundle provides a high-level way of sending expensive logic to background workers.

Configuration

  1. Install the bundle using composer require "dubture/async-bundle"
  2. Add the necessary bundles to your Kernel:
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(

        // register the async bundle
        new Dubture\AsyncBundle\DubtureAsyncBundle(),

        // register the dependencies of the async bundle
        new JMS\DiExtraBundle\JMSDiExtraBundle($this),
        new JMS\AopBundle\JMSAopBundle(),

        // your application bundles here...

    );

    return $bundles;
}
  1. Configure which backend to use:
# app/config/config.yml
dubture_async:
  backend: rabbitmq # one of rabbitmq|resque|sonata|runtime

Usage

Consider the following service:

<services>
    <service class="Acme\Bundle\MediaTranscodingService" id="media_transcoder">
    </service>
</services>
class MediaTranscodingService
{
    public function transcodeFile($sourcePath)
    {
            // ... do some heavy-lifting, e.g. media transcoding
    }
}

If you want to delegate this method to a background worker, this is all you need to do:

use Dubture\AsyncBundle\Annotation\Async;

class MediaTranscodingService
{
    /**
     * @Async
     */
    public function transcodeFile($sourcePath)
    {
            // ... do some heavy-lifting, e.g. media transcoding
    }
}

Now any call to transcodeFile will be intercepted and delegated to a background worker.

Methods annotated with @Async need to adhere to the following contract:

  1. The class declaring the async method must be a service
  2. The methods arguments must be serializable (no resources, e.g. doctrine connections)
  3. The method should not return anything (any return value will be lost)

If you need to react to something happening inside your background worker, you can simply dispatch events when it's done.

The background-worker implementation relies on one of the following bundles:

See Resources/docs for documentation of the specific backends.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固