承接 nebo15/drunken-russian 相关项目开发

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

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

nebo15/drunken-russian

最新稳定版本:1.0.7

Composer 安装命令:

composer require nebo15/drunken-russian

包简介

Tasks (queue) manager for PHP and MongoDB. 100% alcohol free.

README 文档

README

Tasks manager for PHP and MongoDB. 100% alcohol free.

Install via Composer

Run in your project root:

$ composer require nebo15/drunken-russian:dev-master

Before you start

Create some useful indexes

$ vendor/bin/drunken --db=db_name init

Add a clearing task to cron

$ vendor/bin/drunken --db=db_name clear

Config

If you don't want use console options create config file drunken.config.php in the same directory, where script is called. Example of the config you can find in src directory.

Available fields:

  • db - database name
  • workers-dir - string or array, path where workers file are located
  • log_path - path for drunken logs
  • hipchat - hipchat integration:
    • from - sender name
    • token
    • room

Also you can run drunken with option --config="path_to_config"

Example

Adding a task to the queue.

<?php

require_once __DIR__ . '/vendor/autoload.php';

$drunken = new \Drunken\Manager(
    (new MongoClient())->selectDB('db_name')
);

$drunken->add('file', [
    'file' => __DIR__ . 'drunken_lines_.txt',
    'message' => 'The test line'
]);

Returned data from workers

  • true - task successfully completed
  • string - error string, that will be stored in error field
  • string delay:\d+ - delay task for passed seconds

If the worker returns something else task will be marked as 'failed'.

<?php

namespace Drunken;

class FileWorker extends AbstractWorker
{
    public function doThisJob(array $data)
    {
        $result = file_put_contents($data['file'], sprintf("%s\n", $data['message']), FILE_APPEND);
        
        if ($result !== false) {
            return true;
        }
        
        return false;
    }
}

Run workers.

$ vendor/bin/drunken --db=db_name --workers-dir=/path/to/drunken_workers/ do

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-31