Skip to main content

Crate cloacina_workflow

Crate cloacina_workflow 

Source
Expand description

§Cloacina Workflow - Minimal Types for Workflow Authoring

This crate provides the minimal set of types needed to compile Cloacina workflows without pulling in heavy runtime dependencies like database drivers.

§Purpose

Workflow authors who only need to compile workflows can depend on this lightweight crate instead of the full cloacina crate. This provides:

  • Faster compile times
  • Smaller binary sizes
  • Easier cross-compilation (no native database drivers)
  • Clear separation between “authoring workflows” and “running workflows”

§Types Provided

§Usage

use cloacina_workflow::{Context, TaskError};

// Create a context
let mut ctx = Context::<serde_json::Value>::new();
ctx.insert("key", serde_json::json!("value")).unwrap();

// Access data
let value = ctx.get("key").unwrap();

§With the Task Macro

The macros are included by default, so you only need one import:

use cloacina_workflow::{task, packaged_workflow, Context, TaskError};

#[task(id = "my_task", dependencies = [])]
async fn my_task(ctx: &mut Context<serde_json::Value>) -> Result<(), TaskError> {
    ctx.insert("result", serde_json::json!("done"))?;
    Ok(())
}

Re-exports§

pub use context::Context;
pub use error::CheckpointError;
pub use error::ContextError;
pub use error::TaskError;
pub use input_interface::schema_for;
pub use namespace::parse_namespace;
pub use namespace::TaskNamespace;
pub use retry::BackoffStrategy;
pub use retry::RetryCondition;
pub use retry::RetryPolicy;
pub use retry::RetryPolicyBuilder;
pub use task::Task;
pub use task::TaskState;
pub use trigger::Trigger;
pub use trigger::TriggerError;
pub use trigger::TriggerResult;

Modules§

context
Minimal Context for Workflow Authoring
cron_evaluator
Timezone-aware cron expression evaluator
error
Error Types
input_interface
Injectable input interface — JSON Schema generation (CLOACI-I-0128).
namespace
Task namespace management for isolated task execution.
retry
Retry Policy System
task
Task Trait and State
trigger
Trigger types for workflow authoring.

Structs§

InputSlot
One declared input slot of an injectable surface: a named, typed value the surface accepts. schema is a JSON Schema fragment (the type descriptor — schemars-derived for Rust, type-hint-derived for Python) that the UI can render a form from and the server can validate an injection against.

Attribute Macros§

task
Define a task with retry policies and trigger rules.
trigger
Define a trigger that fires a workflow on a schedule or condition.
workflow
Define a workflow as a module containing #[task] functions.