temporalio_workflow/
lib.rs1#![warn(missing_docs)]
2
3extern crate self as temporalio_workflow;
6
7pub use temporalio_common_wasm as common;
8pub use temporalio_macros::{
9 init, query, run, signal, update, update_validator, workflow, workflow_methods,
10};
11
12#[doc(hidden)]
13pub mod __private {
14 pub use futures_util;
15}
16
17mod cancellation;
18#[doc(hidden)]
19pub mod component;
20mod memo;
21#[doc(hidden)]
22pub mod runtime;
23mod workflow_context;
24pub mod workflow_interceptors;
25pub mod workflows;
26
27pub use cancellation::{WorkflowCancellationError, WorkflowCancellationToken};
28pub use memo::{MemoValue, MemoValues};
29#[doc(hidden)]
30pub use runtime::model::{CancellableID, UnblockEvent};
31pub use runtime::model::{TimerResult, WorkflowResult, WorkflowTermination};
32#[doc(hidden)]
33pub use runtime::{SdkWakeGuard, is_sdk_wake};
34pub use temporalio_common_wasm::{
35 ActivityCloseTimeouts, Memo, RetryPolicy,
36 error::{
37 ActivityExecutionError, ChildWorkflowExecutionError, ChildWorkflowStartError, RetryState,
38 TimeoutType, WorkflowSignalError,
39 },
40};
41pub use workflow_context::{
42 ActivityCancellationType, ActivityOptions, BaseWorkflowContext, CancellableFuture,
43 CancellableFutureWithReason, ChildWorkflowCancellationType, ChildWorkflowOptions,
44 ContinueAsNewOptions, ContinueAsNewVersioningBehavior, ExternalWorkflowHandle,
45 LocalActivityOptions, NamespacedWorkflowInfo, NexusOperationCancellationType,
46 NexusOperationOptions, ParentClosePolicy, SignalWorkflowOptions,
47 StartChildWorkflowExecutionFailedCause, StartChildWorkflowOutput, StartedChildWorkflow,
48 StartedNexusOperation, SyncWorkflowContext, TimerOptions, VersioningIntent,
49 WaitConditionOptions, WorkflowContext, WorkflowContextView, WorkflowIdReusePolicy,
50 WorkflowRandomValue,
51};
52#[doc(hidden)]
53pub use workflow_context::{PatchActivationCallback, PatchActivationCaller};
54pub use workflows::{join, join_all, select};
55
56#[macro_export]
57#[doc(hidden)]
58macro_rules! __temporal_select {
59 ($($tokens:tt)*) => {
60 $crate::__private::futures_util::select_biased! { $($tokens)* }
61 };
62}
63
64#[macro_export]
65#[doc(hidden)]
66macro_rules! __temporal_join {
67 ($($tokens:tt)*) => {
68 $crate::__private::futures_util::join!($($tokens)*)
69 };
70}
71
72#[macro_export]
73#[doc(hidden)]
74macro_rules! __temporalio_export_workflow_component {
75 ($export_type:ident) => {
76 $crate::component::__wit_export!(
77 $export_type with_types_in $crate::component::bindings
78 );
79 };
80}
81
82#[macro_export]
83macro_rules! export_workflow_module {
89 ([$($workflow:ty),+ $(,)?]) => {
90 ::temporalio_workflow::export_workflow_module!(
91 [$($workflow),+],
92 interceptor_constructors = [],
93 );
94 };
95 ([$($workflow:ty),+ $(,)?], interceptor_constructors = [$($constructor:expr),* $(,)?] $(,)?) => {
96 const _: () = {
97 struct __TemporalWorkflowModule;
98
99 fn __temporal_workflow_interceptor_constructors() -> ::std::vec::Vec<
100 ::temporalio_workflow::workflow_interceptors::WorkflowInterceptorConstructor,
101 > {
102 ::std::vec![
103 $(
104 ::temporalio_workflow::workflow_interceptors::WorkflowInterceptorConstructor::new(
105 $constructor,
106 )
107 ),*
108 ]
109 }
110
111 impl ::temporalio_workflow::component::StaticWorkflowComponent for __TemporalWorkflowModule {
112 fn list_workflows(
113 ) -> ::std::vec::Vec<::temporalio_workflow::runtime::types::WorkflowDefinitionDescriptor> {
114 ::std::vec![$(<$workflow as ::temporalio_workflow::runtime::entry::WorkflowImplementation>::definition()),*]
115 }
116
117 fn instantiate_workflow(
118 workflow_type: &str,
119 init: ::temporalio_workflow::runtime::types::WorkflowInit,
120 host: ::std::rc::Rc<dyn ::temporalio_workflow::runtime::host::WorkflowHost>,
121 ) -> ::std::result::Result<
122 ::std::boxed::Box<dyn ::temporalio_workflow::runtime::guest::WorkflowInstance>,
123 ::temporalio_workflow::runtime::types::WorkflowFailure,
124 > {
125 match workflow_type {
126 $(
127 name if name == <$workflow as ::temporalio_workflow::runtime::entry::WorkflowImplementation>::name() => {
128 ::temporalio_workflow::component::instantiate_component_workflow_with_interceptor_constructors::<$workflow>(
129 init,
130 host,
131 __temporal_workflow_interceptor_constructors(),
132 )
133 }
134 )*
135 _ => Err(::std::boxed::Box::new(
136 ::temporalio_workflow::common::protos::temporal::api::failure::v1::Failure {
137 message: ::std::format!(
138 "No workflow named '{}' exported by this component",
139 workflow_type
140 ),
141 ..::std::default::Default::default()
142 },
143 )),
144 }
145 }
146 }
147
148 type __TemporalWorkflowComponentExport =
149 ::temporalio_workflow::component::ExportedComponent<__TemporalWorkflowModule>;
150
151 ::temporalio_workflow::__temporalio_export_workflow_component!(
152 __TemporalWorkflowComponentExport
153 );
154 };
155 };
156}