pub struct TaskHubGrpcClient { /* private fields */ }Expand description
Client for managing orchestrations via a gRPC connection to a sidecar.
Implementations§
Source§impl TaskHubGrpcClient
impl TaskHubGrpcClient
Sourcepub async fn new(host_address: &str) -> Result<Self>
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.
§Errors
Returns DurableTaskError::InvalidAddress if host_address is not a
valid URI, or DurableTaskError::ConnectionFailed / DurableTaskError::GrpcError
if the underlying transport cannot be established.
Sourcepub async fn with_options(
host_address: &str,
options: ClientOptions,
) -> Result<Self>
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.
§Errors
Returns DurableTaskError::InvalidAddress if host_address is not a
valid URI, DurableTaskError::Other if TLS options are inconsistent
(e.g. only one of client_cert_pem / client_key_pem is set, or
skip_verify is requested), or DurableTaskError::ConnectionFailed /
DurableTaskError::GrpcError if the underlying transport cannot be
established.
Sourcepub fn from_channel(channel: Channel) -> Self
pub fn from_channel(channel: Channel) -> Self
Create a client from an existing tonic Channel.
Sourcepub fn from_channel_with_options(
channel: Channel,
options: ClientOptions,
) -> Self
pub fn from_channel_with_options( channel: Channel, options: ClientOptions, ) -> Self
Create a client from an existing tonic Channel with custom options.
Sourcepub fn close(self)
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.
Sourcepub async fn schedule_new_orchestration(
&mut self,
orchestrator_name: &str,
input: Option<String>,
instance_id: Option<String>,
start_at: Option<DateTime<Utc>>,
) -> Result<String>
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.
§Errors
Returns DurableTaskError::Other if orchestrator_name or
instance_id is empty, exceeds the configured identifier length, or
contains control characters. Returns DurableTaskError::GrpcError if
the sidecar RPC fails.
Sourcepub async fn get_orchestration_state(
&mut self,
instance_id: &str,
fetch_payloads: bool,
) -> Result<Option<OrchestrationState>>
pub async fn get_orchestration_state( &mut self, instance_id: &str, fetch_payloads: bool, ) -> Result<Option<OrchestrationState>>
Get the current state of an orchestration.
§Errors
Returns DurableTaskError::Other if instance_id is invalid, or
DurableTaskError::GrpcError if the sidecar RPC fails. The successful
result is Ok(None) if the instance does not exist.
Sourcepub async fn wait_for_orchestration_start(
&mut self,
instance_id: &str,
fetch_payloads: bool,
timeout: Option<Duration>,
) -> Result<Option<OrchestrationState>>
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.
§Errors
Returns DurableTaskError::Other if instance_id is invalid,
DurableTaskError::Timeout if timeout elapses before the instance
starts, or DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn wait_for_orchestration_completion(
&mut self,
instance_id: &str,
fetch_payloads: bool,
timeout: Option<Duration>,
) -> Result<Option<OrchestrationState>>
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.
§Errors
Returns DurableTaskError::Other if instance_id is invalid,
DurableTaskError::Timeout if timeout elapses before completion, or
DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn raise_orchestration_event(
&mut self,
instance_id: &str,
event_name: &str,
data: Option<String>,
) -> Result<()>
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.
§Errors
Returns DurableTaskError::Other if instance_id or event_name is
invalid, or DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn terminate_orchestration(
&mut self,
instance_id: &str,
output: Option<String>,
recursive: bool,
) -> Result<()>
pub async fn terminate_orchestration( &mut self, instance_id: &str, output: Option<String>, recursive: bool, ) -> Result<()>
Terminate a running orchestration.
§Errors
Returns DurableTaskError::Other if instance_id is invalid, or
DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn suspend_orchestration(
&mut self,
instance_id: &str,
reason: Option<String>,
) -> Result<()>
pub async fn suspend_orchestration( &mut self, instance_id: &str, reason: Option<String>, ) -> Result<()>
Suspend a running orchestration.
§Errors
Returns DurableTaskError::Other if instance_id is invalid, or
DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn resume_orchestration(
&mut self,
instance_id: &str,
reason: Option<String>,
) -> Result<()>
pub async fn resume_orchestration( &mut self, instance_id: &str, reason: Option<String>, ) -> Result<()>
Resume a suspended orchestration.
§Errors
Returns DurableTaskError::Other if instance_id is invalid, or
DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn purge_orchestration(
&mut self,
instance_id: &str,
recursive: bool,
) -> Result<i32>
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.
§Errors
Returns DurableTaskError::Other if instance_id is invalid, or
DurableTaskError::GrpcError if the sidecar RPC fails.
Sourcepub async fn purge_orchestrations_by_filter(
&mut self,
filter: PurgeInstanceFilter,
recursive: bool,
) -> Result<i32>
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");§Errors
Returns DurableTaskError::GrpcError if the sidecar RPC fails.
Auto Trait Implementations§
impl !Freeze for TaskHubGrpcClient
impl !RefUnwindSafe for TaskHubGrpcClient
impl !UnwindSafe for TaskHubGrpcClient
impl Send for TaskHubGrpcClient
impl Sync for TaskHubGrpcClient
impl Unpin for TaskHubGrpcClient
impl UnsafeUnpin for TaskHubGrpcClient
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
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