Created
August 29, 2013 20:06
-
-
Save blainelang/6382789 to your computer and use it in GitHub Desktop.
Using the maestro API to launch a new workflow instance, crank the engine and get process detail.
Sample PHP code to interact with the Drupal maestro module (workflow engine)
https://drupal.org/project/maestro
This file contains hidden or 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
// Helper function to instantiate maestro engine and step it forward | |
maestro_orchestrator(); | |
// Alternative method to interact with the maestro engine API | |
$maestro = Maestro::createMaestroObject(1); | |
/* | |
That's it! Wherever you want to run the orchestrator, you will place that code. | |
If you look in maestro.module, you will find the function maestro_orchestrator. | |
Inside of it we are trying to acquire a lock based on a defined lock delay (in seconds) configuration parameter. | |
The lock is essentially a simple lock semaphore. If for some reason the lock is not relinquished in a default of 512 seconds, | |
the orchestrator can be run again. You can tune that parameter in the maestro config. | |
Running maestro_orchestrator() makes sure that only one instance of the orchestrator is running. | |
The function of maestro_orchestrator shows how you actually at the api level, run through the queue (cleanQueue method). | |
DO NOT directly call cleanQueue. you will get race conditions. | |
*/ | |
// Instantiate the maestro engine and launch a new workflow instance | |
$maestro = Maestro::createMaestroObject(1); | |
$newprocess = $maestro->engine()->newProcess($template); | |
// Retrieve details for a running workflow instance | |
$process_data = $maestro->engine()->getQueueHistory($new_process_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment