pub struct Client { /* private fields */ }Expand description
Reusable caller-side SDK client for an aion-server deployment.
§Examples
use aion_client::{ClientAuth, ClientBuilder};
let client = ClientBuilder::new("https://aion.example.com")
.with_auth(ClientAuth::bearer("secret-token"))
.with_namespace("tenant-a")
.build()
.await?;
let shared = client.clone();Implementations§
Source§impl Client
impl Client
Sourcepub fn builder(endpoint: impl Into<String>) -> ClientBuilder
pub fn builder(endpoint: impl Into<String>) -> ClientBuilder
Creates a builder for an aion-server endpoint.
Source§impl Client
impl Client
Sourcepub async fn start(
&self,
workflow_type: impl Into<String>,
input: Payload,
opts: StartOptions,
) -> Result<WorkflowHandle, ClientError>
pub async fn start( &self, workflow_type: impl Into<String>, input: Payload, opts: StartOptions, ) -> Result<WorkflowHandle, ClientError>
Starts a workflow and returns the assigned workflow and run identifiers.
§Errors
Returns ClientError when transport, server, or response conversion fails.
Sourcepub async fn start_typed<T>(
&self,
workflow_type: impl Into<String>,
input: &T,
opts: StartOptions,
) -> Result<WorkflowHandle, ClientError>
pub async fn start_typed<T>( &self, workflow_type: impl Into<String>, input: &T, opts: StartOptions, ) -> Result<WorkflowHandle, ClientError>
Starts a workflow after serializing input as JSON.
§Errors
Returns ClientError::InvalidArgument when serialization fails, or the
delegated start error otherwise.
Sourcepub async fn signal(
&self,
workflow_id: &WorkflowId,
run_id: Option<&RunId>,
name: impl Into<String>,
payload: Payload,
) -> Result<(), ClientError>
pub async fn signal( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, name: impl Into<String>, payload: Payload, ) -> Result<(), ClientError>
Sends a signal to the latest run, or to run_id when supplied.
§Errors
Returns ClientError when transport, server, or request conversion fails.
Sourcepub async fn signal_typed<T>(
&self,
workflow_id: &WorkflowId,
run_id: Option<&RunId>,
name: impl Into<String>,
value: &T,
) -> Result<(), ClientError>
pub async fn signal_typed<T>( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, name: impl Into<String>, value: &T, ) -> Result<(), ClientError>
Serializes value as JSON and sends it as a signal payload.
§Errors
Returns ClientError::InvalidArgument when serialization fails, or the
delegated signal error otherwise.
Sourcepub async fn query(
&self,
workflow_id: &WorkflowId,
run_id: Option<&RunId>,
name: impl Into<String>,
args: Payload,
deadline: Duration,
) -> Result<Payload, ClientError>
pub async fn query( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, name: impl Into<String>, args: Payload, deadline: Duration, ) -> Result<Payload, ClientError>
Queries the latest run, or run_id when supplied, with a local deadline.
The current AW protobuf does not yet carry query argument payloads, so a
non-empty args payload returns ClientError::InvalidArgument instead
of being silently dropped.
§Errors
Returns ClientError::QueryTimeout when deadline elapses.
Sourcepub async fn query_typed<A, R>(
&self,
workflow_id: &WorkflowId,
run_id: Option<&RunId>,
name: impl Into<String>,
args: &A,
deadline: Duration,
) -> Result<R, ClientError>
pub async fn query_typed<A, R>( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, name: impl Into<String>, args: &A, deadline: Duration, ) -> Result<R, ClientError>
Serializes args as JSON, queries a workflow, and deserializes the JSON result.
§Errors
Returns ClientError::InvalidArgument when serialization or result
decoding fails, or the delegated query error otherwise.
Sourcepub async fn cancel(
&self,
workflow_id: &WorkflowId,
run_id: Option<&RunId>,
reason: impl Into<String>,
) -> Result<(), ClientError>
pub async fn cancel( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, reason: impl Into<String>, ) -> Result<(), ClientError>
Requests cancellation of the latest run, or run_id when supplied.
Success means the server accepted the cancellation request; it is not a confirmation that the workflow has reached a terminal cancelled state.
§Errors
Returns ClientError when transport, server, or request conversion fails.
Sourcepub async fn list(
&self,
filter: &WorkflowFilter,
page: ListPage,
) -> Result<Vec<WorkflowSummary>, ClientError>
pub async fn list( &self, filter: &WorkflowFilter, page: ListPage, ) -> Result<Vec<WorkflowSummary>, ClientError>
Lists workflows matching a filter.
§Errors
Returns ClientError when transport, server, or response conversion fails.
Sourcepub async fn describe(
&self,
workflow_id: &WorkflowId,
run_id: Option<&RunId>,
) -> Result<WorkflowDescription, ClientError>
pub async fn describe( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, ) -> Result<WorkflowDescription, ClientError>
Describes the latest run, or run_id when supplied.
§Errors
Returns ClientError when transport, server, or response conversion fails.
Sourcepub fn subscribe_workflow(&self, workflow_id: &WorkflowId) -> EventStream
pub fn subscribe_workflow(&self, workflow_id: &WorkflowId) -> EventStream
Subscribes to events for a workflow.
Sourcepub fn subscribe_workflow_from(
&self,
workflow_id: &WorkflowId,
resume_from: NonZeroU64,
) -> EventStream
pub fn subscribe_workflow_from( &self, workflow_id: &WorkflowId, resume_from: NonZeroU64, ) -> EventStream
Subscribes to events for a workflow, attaching from an explicit per-workflow sequence cursor.
resume_from is the first sequence number wanted (resume_from_seq
on the wire); 1 replays the workflow’s full recorded history before
splicing into the live stream, gap-free and duplicate-free.
Sourcepub fn subscribe(&self, filter: WorkflowFilter) -> EventStream
pub fn subscribe(&self, filter: WorkflowFilter) -> EventStream
Subscribes to events selected by the supplied workflow filter.
Sourcepub fn subscribe_firehose(&self) -> EventStream
pub fn subscribe_firehose(&self) -> EventStream
Subscribes to every event visible to this client namespace.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request