aion-client
Rust caller SDK for connecting to an Aion server deployment and operating Aion workflows. The crate exposes connect plus the seven workflow operations: start, signal, query, cancel, list, describe, and subscribe.
Key public types
Client,ClientBuilder,ClientAuth, andTlsOptionsconfigure gRPC connections.WorkflowHandlescopes operations to a started workflow run.StartOptions,WorkflowDescription, andListPagemodel workflow operations.EventStream,ResumingEventStream, andSubscribeTargetstream events.to_payloadandfrom_payloadbridge typed values withaion-corepayloads.
Install
[]
= "0.4.0"
Server prerequisite
Run an Aion server (aion server --config <file>) that implements the AW workflow API. The runnable example uses the AL-007 server fixture defaults:
# optional
See examples/seven_operations.rs for a complete program covering all seven operations.
Connect
use ;
let mut builder = new
.with_namespace;
if let Ok = var
let client = builder.build.await?;
start
start_typed serializes a typed value to JSON and returns a WorkflowHandle that carries the workflow and run IDs. StartOptions::idempotency_key makes caller retries safe: the same request returns the original handle and conflicting reuse returns ClientError::AlreadyExists.
use StartOptions;
use Serialize;
let handle = client
.start_typed
.await?;
signal
handle
.signal_typed
.await?;
query
Query results can be decoded into any serde::Deserialize type. The current AW query request has no argument payload field, so pass &() for typed query arguments.
use Deserialize;
use Duration;
let state: EchoState = handle.query_typed.await?;
list
use ListPage;
use WorkflowFilter;
let summaries = client
.list
.await?;
describe
let description = handle.describe.await?;
println!;
cancel
Cancellation is a cooperative request: success means the server accepted it, not that the workflow has already reached a terminal state.
handle.cancel.await?;
subscribe
subscribe returns a Stream<Item = Result<Event, ClientError>>. Transient disconnects are retried with the next per-workflow sequence number so delivered events are gap-free and duplicate-free; terminal failures are yielded as stream errors.
use StreamExt;
let mut events = handle.subscribe;
while let Some = events.next.await
Typed and raw payloads
Typed helpers (start_typed, signal_typed, query_typed, to_payload, from_payload) use JSON by default. For pre-serialized or non-JSON data, use the raw aion_core::Payload escape hatch with the raw operation variants:
use ;
let raw = new;
handle.signal.await?;
Branching on errors
Every operation returns the shared branchable taxonomy via ClientError.
Each variant carries an ErrorDetail with the server's human detail message
and, when the wire supplied one, the structured error_type discriminator.
use ClientError;
match handle..await