#[allow(clippy::all, unused_imports, dead_code)]
pub mod multi_v1_multi_service_temporal {
use anyhow::Result;
use std::time::Duration;
use crate::temporal_runtime;
use crate::multi::v1::*;
impl temporal_runtime::TemporalProtoMessage for AlphaInput {
const MESSAGE_TYPE: &'static str = "multi.v1.AlphaInput";
}
impl temporal_runtime::TemporalProtoMessage for AlphaOutput {
const MESSAGE_TYPE: &'static str = "multi.v1.AlphaOutput";
}
impl temporal_runtime::TemporalProtoMessage for BetaInput {
const MESSAGE_TYPE: &'static str = "multi.v1.BetaInput";
}
impl temporal_runtime::TemporalProtoMessage for BetaOutput {
const MESSAGE_TYPE: &'static str = "multi.v1.BetaOutput";
}
pub const ALPHA_WORKFLOW_NAME: &str = "multi.v1.MultiService/Alpha";
pub const ALPHA_TASK_QUEUE: &str = "multi";
pub const BETA_WORKFLOW_NAME: &str = "multi.v1.MultiService/Beta";
pub const BETA_TASK_QUEUE: &str = "multi-beta";
fn alpha_id(input: &AlphaInput) -> String {
format!("alpha-{}", input.label)
}
pub struct MultiServiceClient {
client: temporal_runtime::TemporalClient,
}
impl MultiServiceClient {
pub fn new(client: temporal_runtime::TemporalClient) -> Self {
Self { client }
}
pub fn inner(&self) -> &temporal_runtime::TemporalClient {
&self.client
}
pub async fn alpha(
&self,
input: AlphaInput,
opts: AlphaStartOptions,
) -> Result<AlphaHandle> {
let workflow_id = opts.workflow_id.unwrap_or_else(|| {
alpha_id(&input)
});
let task_queue = opts.task_queue.unwrap_or_else(|| "multi".to_string());
let inner = temporal_runtime::start_workflow_proto(
&self.client,
ALPHA_WORKFLOW_NAME,
&workflow_id,
&task_queue,
&input,
opts.id_reuse_policy,
opts.execution_timeout,
opts.run_timeout,
opts.task_timeout,
).await?;
Ok(AlphaHandle { inner })
}
pub fn alpha_handle(&self, workflow_id: impl Into<String>) -> AlphaHandle {
AlphaHandle {
inner: temporal_runtime::attach_handle(&self.client, workflow_id.into()),
}
}
pub async fn beta(
&self,
input: BetaInput,
opts: BetaStartOptions,
) -> Result<BetaHandle> {
let workflow_id = opts.workflow_id.unwrap_or_else(|| {
temporal_runtime::random_workflow_id()
});
let task_queue = opts.task_queue.unwrap_or_else(|| "multi-beta".to_string());
let inner = temporal_runtime::start_workflow_proto(
&self.client,
BETA_WORKFLOW_NAME,
&workflow_id,
&task_queue,
&input,
opts.id_reuse_policy,
opts.execution_timeout,
opts.run_timeout,
opts.task_timeout,
).await?;
Ok(BetaHandle { inner })
}
pub fn beta_handle(&self, workflow_id: impl Into<String>) -> BetaHandle {
BetaHandle {
inner: temporal_runtime::attach_handle(&self.client, workflow_id.into()),
}
}
}
#[derive(Debug, Default, Clone)]
pub struct AlphaStartOptions {
pub workflow_id: Option<String>,
pub task_queue: Option<String>,
pub id_reuse_policy: Option<temporal_runtime::WorkflowIdReusePolicy>,
pub execution_timeout: Option<Duration>,
pub run_timeout: Option<Duration>,
pub task_timeout: Option<Duration>,
}
pub struct AlphaHandle {
inner: temporal_runtime::WorkflowHandle,
}
impl AlphaHandle {
pub fn workflow_id(&self) -> &str {
self.inner.workflow_id()
}
pub async fn result(&self) -> Result<AlphaOutput> {
temporal_runtime::wait_result_proto::<AlphaOutput>(&self.inner).await
}
}
#[derive(Debug, Default, Clone)]
pub struct BetaStartOptions {
pub workflow_id: Option<String>,
pub task_queue: Option<String>,
pub id_reuse_policy: Option<temporal_runtime::WorkflowIdReusePolicy>,
pub execution_timeout: Option<Duration>,
pub run_timeout: Option<Duration>,
pub task_timeout: Option<Duration>,
}
impl BetaStartOptions {
pub fn default_run_timeout() -> Duration {
Duration::from_secs(900)
}
}
pub struct BetaHandle {
inner: temporal_runtime::WorkflowHandle,
}
impl BetaHandle {
pub fn workflow_id(&self) -> &str {
self.inner.workflow_id()
}
pub async fn result(&self) -> Result<BetaOutput> {
temporal_runtime::wait_result_proto::<BetaOutput>(&self.inner).await
}
}
}