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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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");Auto Trait Implementations§
impl !Freeze for TaskHubGrpcClient
impl !RefUnwindSafe for TaskHubGrpcClient
impl Send for TaskHubGrpcClient
impl Sync for TaskHubGrpcClient
impl Unpin for TaskHubGrpcClient
impl UnsafeUnpin for TaskHubGrpcClient
impl !UnwindSafe 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