Skip to main content

Client

Struct Client 

Source
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

Source

pub fn builder(endpoint: impl Into<String>) -> ClientBuilder

Creates a builder for an aion-server endpoint.

Source§

impl Client

Source

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.

Source

pub async fn start_typed<T>( &self, workflow_type: impl Into<String>, input: &T, opts: StartOptions, ) -> Result<WorkflowHandle, ClientError>
where T: Serialize + ?Sized,

Starts a workflow after serializing input as JSON.

§Errors

Returns ClientError::InvalidArgument when serialization fails, or the delegated start error otherwise.

Source

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.

Source

pub async fn signal_typed<T>( &self, workflow_id: &WorkflowId, run_id: Option<&RunId>, name: impl Into<String>, value: &T, ) -> Result<(), ClientError>
where T: Serialize + ?Sized,

Serializes value as JSON and sends it as a signal payload.

§Errors

Returns ClientError::InvalidArgument when serialization fails, or the delegated signal error otherwise.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn subscribe_workflow(&self, workflow_id: &WorkflowId) -> EventStream

Subscribes to events for a workflow.

Source

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.

Source

pub fn subscribe(&self, filter: WorkflowFilter) -> EventStream

Subscribes to events selected by the supplied workflow filter.

Source

pub fn subscribe_firehose(&self) -> EventStream

Subscribes to every event visible to this client namespace.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more