Skip to main content

TaskHubGrpcClient

Struct TaskHubGrpcClient 

Source
pub struct TaskHubGrpcClient { /* private fields */ }
Expand description

Client for managing orchestrations via a gRPC connection to a sidecar.

Implementations§

Source§

impl TaskHubGrpcClient

Source

pub async fn new(host_address: &str) -> Result<Self>

Create a new client connected to the given host address.

The default address is http://localhost:4001.

Source

pub async fn with_options( host_address: &str, options: ClientOptions, ) -> Result<Self>

Create a new client connected to the given host address with custom options.

Source

pub fn from_channel(channel: Channel) -> Self

Create a client from an existing tonic Channel.

Source

pub fn from_channel_with_options( channel: Channel, options: ClientOptions, ) -> Self

Create a client from an existing tonic Channel with custom options.

Source

pub fn close(self)

Close the client, releasing the underlying gRPC channel.

The channel is also released when the client is dropped. This method provides an explicit, named alternative.

Source

pub async fn schedule_new_orchestration( &mut self, orchestrator_name: &str, input: Option<String>, instance_id: Option<String>, start_at: Option<DateTime<Utc>>, ) -> Result<String>

Schedule a new orchestration instance and return its instance ID.

Source

pub async fn get_orchestration_state( &mut self, instance_id: &str, fetch_payloads: bool, ) -> Result<Option<OrchestrationState>>

Get the current state of an orchestration.

Source

pub async fn wait_for_orchestration_start( &mut self, instance_id: &str, fetch_payloads: bool, timeout: Option<Duration>, ) -> Result<Option<OrchestrationState>>

Wait for an orchestration to start running.

Source

pub async fn wait_for_orchestration_completion( &mut self, instance_id: &str, fetch_payloads: bool, timeout: Option<Duration>, ) -> Result<Option<OrchestrationState>>

Wait for an orchestration to reach a terminal state.

Source

pub async fn raise_orchestration_event( &mut self, instance_id: &str, event_name: &str, data: Option<String>, ) -> Result<()>

Raise an event to an orchestration instance.

Source

pub async fn terminate_orchestration( &mut self, instance_id: &str, output: Option<String>, recursive: bool, ) -> Result<()>

Terminate a running orchestration.

Source

pub async fn suspend_orchestration( &mut self, instance_id: &str, reason: Option<String>, ) -> Result<()>

Suspend a running orchestration.

Source

pub async fn resume_orchestration( &mut self, instance_id: &str, reason: Option<String>, ) -> Result<()>

Resume a suspended orchestration.

Source

pub async fn purge_orchestration( &mut self, instance_id: &str, recursive: bool, ) -> Result<i32>

Purge an orchestration’s history and state by instance ID.

Returns the number of deleted instances.

Source

pub async fn purge_orchestrations_by_filter( &mut self, filter: PurgeInstanceFilter, recursive: bool, ) -> Result<i32>

Purge orchestrations matching the given filter criteria.

Returns the number of deleted instances.

§Examples
use dapr_durabletask::api::{OrchestrationStatus, PurgeInstanceFilter};

let filter = PurgeInstanceFilter::new()
    .with_created_time_from(chrono::Utc::now() - chrono::Duration::hours(24))
    .with_runtime_status([OrchestrationStatus::Completed, OrchestrationStatus::Failed]);

let deleted = client.purge_orchestrations_by_filter(filter, false).await.unwrap();
println!("Deleted {deleted} orchestrations");

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<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