Skip to main content

temporalio_workflow/workflow_interceptors/
nexus.rs

1use super::*;
2use crate::{NexusOperationOptions, StartedNexusOperation, runtime::model::NexusStartResult};
3use temporalio_common_wasm::protos::temporal::api::failure::v1::Failure;
4
5impl WorkflowInterceptorContext {
6    /// Start a Nexus operation through the workflow outbound interceptor chain.
7    pub fn start_nexus_operation(
8        &self,
9        opts: NexusOperationOptions,
10    ) -> impl CancellableFuture<Output = NexusStartResult> {
11        self.base.start_nexus_operation(opts)
12    }
13}
14
15/// Input passed to [`WorkflowInterceptor::start_nexus_operation`].
16#[non_exhaustive]
17pub struct StartNexusOperationInput {
18    options: NexusOperationOptions,
19}
20
21impl StartNexusOperationInput {
22    pub(crate) fn new(options: NexusOperationOptions) -> Self {
23        Self { options }
24    }
25
26    pub(crate) fn into_options(self) -> NexusOperationOptions {
27        self.options
28    }
29
30    /// Nexus operation options.
31    pub fn options(&self) -> &NexusOperationOptions {
32        &self.options
33    }
34
35    /// Mutably access Nexus operation options.
36    pub fn options_mut(&mut self) -> &mut NexusOperationOptions {
37        &mut self.options
38    }
39}
40
41/// Result of an intercepted Nexus operation start.
42pub type StartNexusOperationResult = Result<StartedNexusOperation, Failure>;
43
44outbound_chain!(
45    call_start_nexus_operation,
46    start_nexus_operation,
47    WorkflowInterceptorContext,
48    StartNexusOperationInput,
49    CancellableWorkflowOutboundFuture<StartNexusOperationResult>
50);