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