nebo15 / drunken-russian
Tasks (queue) manager for PHP and MongoDB. 100% alcohol free.
Installs: 1 098
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 13
Forks: 0
Open Issues: 0
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~6.0
- hipchat/hipchat-php: 1.*
- monolog/monolog: 1.*
This package is not auto-updated.
Last update: 2024-11-09 18:22:16 UTC
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 completedstring
- error string, that will be stored in error fieldstring
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