Skip to main content
Cloacina Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Registry

cloacina::workflow::registry Rust

Global workflow registry for automatic workflow registration.

This module provides the global registry used by the workflow! macro to automatically register workflows at startup.

Functions

cloacina::workflow::registry::register_workflow_constructor

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");
}

cloacina::workflow::registry::global_workflow_registry

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()
}

cloacina::workflow::registry::get_all_workflows

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()
}