承接 treehouselabs/worker-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

treehouselabs/worker-bundle

最新稳定版本:2.0.1

Composer 安装命令:

composer require treehouselabs/worker-bundle

包简介

Adds worker functionality to a Symfony2 project, using Beanstalkd as the message queue

README 文档

README

This bundle is no longer maintained. It will still work with Symfony versions ^2.8|^3.0|^4.0 and is archived here to not break existing applications using it. However it will not get maintenance updates or even security fixes.

If you need queue/worker functionality in your project, there are far better solutions right now to look at:

Previous readme below 👇

Worker bundle

Latest Version on Packagist Software License Build Status Coverage Status Quality Score

A Symfony bundle that adds worker functionality to your project, using Beanstalkd as the message queue.

Installation

For this process, we assume you have a Beanstalk server up and running.

Install via Composer:

$ composer require treehouselabs/worker-bundle

Enable the bundle:

# app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...

            new TreeHouse\WorkerBundle\TreeHouseWorkerBundle(),
        ];

        // ...
    }

    // ...
}

Configuration

Define a queue and you're good to go:

# app/config/config.yml

tree_house_worker:
  queue:
    server: localhost

The bundle also supports the PheanstalkBundle, if you're using that:

# app/config/config.yml

tree_house_worker:
  pheanstalk: leezy.pheanstalk

Basic Usage

The bundle creates a QueueManager service, which you can use to manage jobs. The manager has services registered to execute specific tasks, called executors. An executor receives a job from the QueueManager and processes it.

Defining executors

First you need to register an executor, and tag it as such:

# src/AppBundle/Executor/HelloWorldExecutor.php

use TreeHouse\WorkerBundle\Executor\AbstractExecutor;

class HelloWorldExecutor extends AbstractExecutor
{
    public function getName()
    {
        return 'hello.world';
    }

    public function configurePayload(OptionsResolver $resolver)
    {
        $resolver->setRequired(0);
    }

    public function execute(array $payload)
    {
        $name = array_shift($payload);

        # process stuff here, in this example we just print something
        echo 'Hello, ' . $name;

        return true;
    }
}
# app/config/services.yml
app.executor.hello_world:
  class: AppBundle/Executor/HelloWorldExecutor
  tags:
    - { name: tree_house.worker.executor }

Scheduling jobs

Now you can add jobs, either via code or using the worker:schedule command:

In your application's code:

$queueManager = $container->get('tree_house.worker.queue_manager');
$queueManager->add('hello.world', ['Peter']);

Using the command:

php app/console worker:schedule hello.world Peter

Working jobs

A worker can now receive and process these jobs via the console:

php app/console worker:run

# prints:
# Working hello.world with payload ["Peter"]
# Hello, Peter
# Completed job in 1ms with result: true

You can run workers by adding them to your crontab, creating a Supervisor program for it, or whatever your preferred method is.

Documentation

  1. Message queues & workers
  2. The QueueManager
  3. Executors
  4. Working jobs

Security

If you discover any security related issues, please email dev@treehouse.nl instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

Credits

treehouselabs/worker-bundle 适用场景与选型建议

treehouselabs/worker-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57.75k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2015 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「beanstalk」 「worker」 「beanstalkd」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 treehouselabs/worker-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 treehouselabs/worker-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 treehouselabs/worker-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 7
  • Forks: 7
  • 开发语言: PHP

其他信息

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