Last active
December 31, 2015 01:59
-
-
Save zircote/7917756 to your computer and use it in GitHub Desktop.
Rhubarb 3.2-dev use examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @license http://www.apache.org/licenses/LICENSE-2.0 | |
* Copyright [2013] [Robert Allen] | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
* | |
* @package Rhubarb | |
* @category Examples | |
* | |
*/ | |
use Rhubarb\Rhubarb; | |
use Rhubarb\Task\Body\Python as PythonTask; | |
use Rhubarb\Task\Body\Python\Kwargs; | |
use Rhubarb\Task\Signature; | |
$config = include('redis_configuration.php'); | |
$rhubarb = new Rhubarb($config); | |
$kwargs = new Kwargs(array('arg1' => 1, 'arg2' => 2)); | |
$argsPython = new PythonTask(array(1, 2), $kwargs); | |
/* @var Signature $add */ | |
$add = $rhubarb->task('app.add'); | |
/* @var Signature $add */ | |
$add = $rhubarb->task('app.add')->si($argsPython); | |
/* | |
* Celery Direct Queue Routing for Workers: | |
* | |
* Given the routing queue as: [email protected] | |
* and Config Option: CELERY_WORKER_DIRECT = True | |
* The following will route the request to a specific worker with a 60 second delay: | |
* | |
*/ | |
$asyncResult = $add->delay( | |
$argsPython, | |
array('countdown' => 60), | |
array('routing_key' => '[email protected]', 'exchange' => 'C.dq') | |
); | |
$result = $asyncResult->get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @license http://www.apache.org/licenses/LICENSE-2.0 | |
* Copyright [2013] [Robert Allen] | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
* | |
* @package Rhubarb | |
* @category Examples | |
*/ | |
return array( | |
'broker' => array( | |
'connection' => 'redis://localhost:6379/0' | |
), | |
'result_store' => array( | |
'connection' => 'redis://localhost:6379/0' | |
), | |
'tasks' => array( | |
array( | |
'name' => 'app.add', // c_type | |
'callbacks' => array( | |
array('name' => 'app.sum') | |
), | |
'errbacks' => array( | |
array('name' => 'app.debug') | |
), | |
'timelimit' => 30 | |
), | |
array( | |
'name' => 'app.sum', // c_type | |
'errbacks' => array( | |
array('name' => 'app.debug') | |
), | |
array( | |
'name' => 'app.debug', // c_type | |
), | |
'logger' => array( | |
'loggers' => array( | |
'Rhubarb' => array( | |
'appenders' => array( | |
'rhubarb_file', | |
'rhubarb_console' | |
), array( | |
'level' => 'DEBUG', | |
'appenders' => array('default'), | |
), | |
) | |
), | |
'appenders' => array( | |
'rhubarb_console' => array( | |
'class' => 'LoggerAppenderFile', | |
'layout' => array( | |
'class' => 'LoggerLayoutConsole' | |
), | |
), | |
'rhubarb_file' => array( | |
'class' => 'LoggerAppenderFile', | |
'layout' => array( | |
'class' => 'LoggerLayoutSimple' | |
), | |
'params' => array( | |
'file' => '/var/log/rhubarb.log', | |
'append' => true | |
) | |
) | |
) | |
) | |
) | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @license http://www.apache.org/licenses/LICENSE-2.0 | |
* Copyright [2013] [Robert Allen] | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
* | |
* @package Rhubarb | |
* @category Examples | |
* | |
*/ | |
use Rhubarb\Rhubarb; | |
use Rhubarb\Task\Body\Python as PythonTask; | |
use Rhubarb\Task\Body\Python\Kwargs; | |
use Rhubarb\Task\Signature; | |
$config = include('redis_configuration.php'); | |
$rhubarb = new Rhubarb($config); | |
$kwargs = new Kwargs(array('arg1' => 1, 'arg2' => 2)); | |
$argsPython = new PythonTask(array(1, 2), $kwargs); | |
/* @var Signature $add */ | |
$add = $rhubarb->task('app.add'); | |
$asyncResult = $add->delay($argsPython, array('countdown' => 60)); | |
$result = $asyncResult->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment