Registry
Global workflow registry for automatic workflow registration.
This module provides the global registry used by the workflow! macro
to automatically register workflows at startup.
pub
fn register_workflow_constructor < F > (workflow_name : String , constructor : F) where F : Fn () -> Workflow + Send + Sync + 'static ,
Register a workflow constructor function globally
This is used internally by the workflow! macro to automatically register workflows.
Most users won’t call this directly.
Source
pub fn register_workflow_constructor<F>(workflow_name: String, constructor: F)
where
F: Fn() -> Workflow + Send + Sync + 'static,
{
let mut registry = GLOBAL_WORKFLOW_REGISTRY.write();
registry.insert(workflow_name, Box::new(constructor));
tracing::debug!("Successfully registered workflow constructor");
}
pub
fn global_workflow_registry () -> GlobalWorkflowRegistry
Get the global workflow registry
This provides access to the global workflow registry used by the macro system. Most users won’t need to call this directly.
Source
pub fn global_workflow_registry() -> GlobalWorkflowRegistry {
GLOBAL_WORKFLOW_REGISTRY.clone()
}
pub
fn get_all_workflows () -> Vec < Workflow >
Get all workflows from the global registry
Returns instances of all workflows registered with the workflow! macro.
Examples:
use cloacina::*;
let all_workflows = get_all_workflows();
for workflow in all_workflows {
println!("Found workflow: {}", workflow.name());
}
Source
pub fn get_all_workflows() -> Vec<Workflow> {
let registry = GLOBAL_WORKFLOW_REGISTRY.read();
registry.values().map(|constructor| constructor()).collect()
}