Skip to content

Quick Start (Embedded)

Run a one-task workflow inside your own process, against a local SQLite database. Pick your language — the engine is the same.

Add the dependencies — cloacina = "0.12" and cloacina-workflow = "0.12" (the task macro generates code that references it directly), plus tokio and serde_json — then:

use cloacina::executor::WorkflowExecutor;
use cloacina::runner::{DefaultRunner, DefaultRunnerConfig};
use cloacina::{task, workflow, Context, TaskError};
#[workflow(name = "greeting", description = "Say hello")]
pub mod greeting {
use super::*;
#[task]
pub async fn hello(ctx: &mut Context<serde_json::Value>) -> Result<(), TaskError> {
ctx.insert("message", serde_json::json!("Hello World!"))?;
Ok(())
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let runner = DefaultRunner::with_config(
"sqlite://app.db",
DefaultRunnerConfig::default(),
).await?;
let result = runner.execute("greeting", Context::new()).await?;
println!("status: {:?}", result.status);
runner.shutdown().await?;
Ok(())
}

Run with cargo run.

You just defined a workflow, ran it in-process, and persisted its state to SQLite.