@temporalio/core-bridge 1.5.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/Cargo.lock +304 -112
  2. package/lib/index.d.ts +8 -6
  3. package/lib/index.js.map +1 -1
  4. package/package.json +9 -4
  5. package/releases/aarch64-apple-darwin/index.node +0 -0
  6. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  7. package/releases/x86_64-apple-darwin/index.node +0 -0
  8. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  9. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  10. package/sdk-core/.buildkite/docker/Dockerfile +2 -2
  11. package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
  12. package/sdk-core/.buildkite/pipeline.yml +2 -4
  13. package/sdk-core/.cargo/config.toml +5 -2
  14. package/sdk-core/.github/workflows/heavy.yml +29 -0
  15. package/sdk-core/Cargo.toml +1 -1
  16. package/sdk-core/README.md +20 -10
  17. package/sdk-core/client/src/lib.rs +215 -39
  18. package/sdk-core/client/src/metrics.rs +17 -8
  19. package/sdk-core/client/src/raw.rs +4 -4
  20. package/sdk-core/client/src/retry.rs +32 -20
  21. package/sdk-core/core/Cargo.toml +25 -12
  22. package/sdk-core/core/src/abstractions/take_cell.rs +28 -0
  23. package/sdk-core/core/src/abstractions.rs +204 -14
  24. package/sdk-core/core/src/core_tests/activity_tasks.rs +143 -50
  25. package/sdk-core/core/src/core_tests/child_workflows.rs +6 -5
  26. package/sdk-core/core/src/core_tests/determinism.rs +165 -2
  27. package/sdk-core/core/src/core_tests/local_activities.rs +431 -43
  28. package/sdk-core/core/src/core_tests/queries.rs +34 -16
  29. package/sdk-core/core/src/core_tests/workers.rs +8 -5
  30. package/sdk-core/core/src/core_tests/workflow_tasks.rs +588 -55
  31. package/sdk-core/core/src/ephemeral_server/mod.rs +113 -12
  32. package/sdk-core/core/src/internal_flags.rs +155 -0
  33. package/sdk-core/core/src/lib.rs +16 -9
  34. package/sdk-core/core/src/protosext/mod.rs +1 -1
  35. package/sdk-core/core/src/replay/mod.rs +16 -27
  36. package/sdk-core/core/src/telemetry/log_export.rs +1 -1
  37. package/sdk-core/core/src/telemetry/metrics.rs +69 -35
  38. package/sdk-core/core/src/telemetry/mod.rs +60 -21
  39. package/sdk-core/core/src/telemetry/prometheus_server.rs +19 -13
  40. package/sdk-core/core/src/test_help/mod.rs +73 -14
  41. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +119 -160
  42. package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
  43. package/sdk-core/core/src/worker/activities/local_activities.rs +379 -129
  44. package/sdk-core/core/src/worker/activities.rs +350 -175
  45. package/sdk-core/core/src/worker/client/mocks.rs +22 -2
  46. package/sdk-core/core/src/worker/client.rs +18 -2
  47. package/sdk-core/core/src/worker/mod.rs +183 -64
  48. package/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
  49. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +3 -5
  50. package/sdk-core/core/src/worker/workflow/history_update.rs +916 -277
  51. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +216 -183
  52. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +9 -12
  53. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +7 -9
  54. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +160 -87
  55. package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -14
  56. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -9
  57. package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +14 -17
  58. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +242 -110
  59. package/sdk-core/core/src/worker/workflow/machines/mod.rs +27 -19
  60. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +9 -11
  61. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +321 -206
  62. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +13 -18
  63. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +20 -29
  64. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
  65. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +257 -51
  66. package/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
  67. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +310 -150
  68. package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +17 -20
  69. package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +31 -15
  70. package/sdk-core/core/src/worker/workflow/managed_run.rs +1052 -380
  71. package/sdk-core/core/src/worker/workflow/mod.rs +598 -390
  72. package/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
  73. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +137 -0
  74. package/sdk-core/core/src/worker/workflow/wft_poller.rs +1 -4
  75. package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
  76. package/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
  77. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +469 -718
  78. package/sdk-core/core-api/Cargo.toml +2 -1
  79. package/sdk-core/core-api/src/errors.rs +1 -34
  80. package/sdk-core/core-api/src/lib.rs +19 -9
  81. package/sdk-core/core-api/src/telemetry.rs +4 -6
  82. package/sdk-core/core-api/src/worker.rs +19 -1
  83. package/sdk-core/etc/deps.svg +115 -140
  84. package/sdk-core/etc/regen-depgraph.sh +5 -0
  85. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +86 -61
  86. package/sdk-core/fsm/rustfsm_trait/src/lib.rs +29 -71
  87. package/sdk-core/histories/ends_empty_wft_complete.bin +0 -0
  88. package/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
  89. package/sdk-core/histories/old_change_marker_format.bin +0 -0
  90. package/sdk-core/protos/api_upstream/.github/CODEOWNERS +2 -1
  91. package/sdk-core/protos/api_upstream/Makefile +6 -6
  92. package/sdk-core/protos/api_upstream/build/go.mod +7 -0
  93. package/sdk-core/protos/api_upstream/build/go.sum +5 -0
  94. package/sdk-core/protos/api_upstream/build/tools.go +29 -0
  95. package/sdk-core/protos/api_upstream/go.mod +6 -0
  96. package/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +9 -2
  97. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +7 -26
  98. package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
  99. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
  100. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +3 -7
  101. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
  102. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +8 -8
  103. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +25 -2
  104. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
  105. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
  106. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
  107. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
  108. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
  109. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +24 -19
  110. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
  111. package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
  112. package/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
  113. package/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
  114. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +49 -26
  115. package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +4 -2
  116. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +5 -2
  117. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -2
  118. package/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +57 -0
  119. package/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
  120. package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
  121. package/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
  122. package/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
  123. package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -2
  124. package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +71 -6
  125. package/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
  126. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +2 -2
  127. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +64 -28
  128. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +4 -4
  129. package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +7 -8
  130. package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +10 -7
  131. package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +19 -30
  132. package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
  133. package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
  134. package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +8 -0
  135. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +67 -60
  136. package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +85 -84
  137. package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +9 -3
  138. package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
  139. package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
  140. package/sdk-core/sdk/Cargo.toml +5 -4
  141. package/sdk-core/sdk/src/lib.rs +108 -26
  142. package/sdk-core/sdk/src/workflow_context/options.rs +7 -1
  143. package/sdk-core/sdk/src/workflow_context.rs +24 -17
  144. package/sdk-core/sdk/src/workflow_future.rs +16 -15
  145. package/sdk-core/sdk-core-protos/Cargo.toml +5 -2
  146. package/sdk-core/sdk-core-protos/build.rs +36 -2
  147. package/sdk-core/sdk-core-protos/src/history_builder.rs +138 -106
  148. package/sdk-core/sdk-core-protos/src/history_info.rs +10 -1
  149. package/sdk-core/sdk-core-protos/src/lib.rs +272 -87
  150. package/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
  151. package/sdk-core/test-utils/Cargo.toml +3 -1
  152. package/sdk-core/test-utils/src/canned_histories.rs +106 -296
  153. package/sdk-core/test-utils/src/histfetch.rs +1 -1
  154. package/sdk-core/test-utils/src/lib.rs +82 -23
  155. package/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
  156. package/sdk-core/test-utils/src/workflows.rs +29 -0
  157. package/sdk-core/tests/fuzzy_workflow.rs +130 -0
  158. package/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
  159. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
  160. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +10 -5
  161. package/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
  162. package/sdk-core/tests/integ_tests/polling_tests.rs +4 -47
  163. package/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
  164. package/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
  165. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +161 -72
  166. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
  167. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
  168. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +80 -3
  169. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
  170. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
  171. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +94 -200
  172. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +2 -4
  173. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +34 -28
  174. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +76 -7
  175. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
  176. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
  177. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
  178. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
  179. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +7 -8
  180. package/sdk-core/tests/integ_tests/workflow_tests.rs +13 -14
  181. package/sdk-core/tests/main.rs +3 -13
  182. package/sdk-core/tests/runner.rs +75 -36
  183. package/sdk-core/tests/wf_input_replay.rs +32 -0
  184. package/src/conversions.rs +14 -8
  185. package/src/runtime.rs +9 -8
  186. package/ts/index.ts +8 -6
  187. package/sdk-core/bridge-ffi/Cargo.toml +0 -24
  188. package/sdk-core/bridge-ffi/LICENSE.txt +0 -23
  189. package/sdk-core/bridge-ffi/build.rs +0 -25
  190. package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -224
  191. package/sdk-core/bridge-ffi/src/lib.rs +0 -746
  192. package/sdk-core/bridge-ffi/src/wrappers.rs +0 -221
  193. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
  194. package/sdk-core/sdk/src/conversions.rs +0 -8
@@ -12,11 +12,18 @@ mod history_info;
12
12
  mod task_token;
13
13
 
14
14
  #[cfg(feature = "history_builders")]
15
- pub use history_builder::{default_wes_attribs, TestHistoryBuilder, DEFAULT_WORKFLOW_TYPE};
15
+ pub use history_builder::{
16
+ default_act_sched, default_wes_attribs, TestHistoryBuilder, DEFAULT_ACTIVITY_TYPE,
17
+ DEFAULT_WORKFLOW_TYPE,
18
+ };
16
19
  #[cfg(feature = "history_builders")]
17
20
  pub use history_info::HistoryInfo;
18
21
  pub use task_token::TaskToken;
19
22
 
23
+ pub static ENCODING_PAYLOAD_KEY: &str = "encoding";
24
+ pub static JSON_ENCODING_VAL: &str = "json/plain";
25
+ pub static PATCHED_MARKER_DETAILS_KEY: &str = "patch-data";
26
+
20
27
  #[allow(clippy::large_enum_variant, clippy::derive_partial_eq_without_eq)]
21
28
  // I'd prefer not to do this, but there are some generated things that just don't need it.
22
29
  #[allow(missing_docs)]
@@ -25,10 +32,14 @@ pub mod coresdk {
25
32
 
26
33
  tonic::include_proto!("coresdk");
27
34
 
28
- use crate::temporal::api::{
29
- common::v1::{ActivityType, Payload, Payloads, WorkflowExecution},
30
- failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
31
- workflowservice::v1::PollActivityTaskQueueResponse,
35
+ use crate::{
36
+ temporal::api::{
37
+ common::v1::{Payload, Payloads, WorkflowExecution},
38
+ enums::v1::WorkflowTaskFailedCause,
39
+ failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
40
+ workflowservice::v1::PollActivityTaskQueueResponse,
41
+ },
42
+ ENCODING_PAYLOAD_KEY, JSON_ENCODING_VAL,
32
43
  };
33
44
  use activity_task::ActivityTask;
34
45
  use serde::{Deserialize, Serialize};
@@ -67,7 +78,7 @@ pub mod coresdk {
67
78
  fmt_tt(&self.task_token),
68
79
  )?;
69
80
  if let Some(r) = self.result.as_ref().and_then(|r| r.status.as_ref()) {
70
- write!(f, ", {}", r)?;
81
+ write!(f, ", {r}")?;
71
82
  } else {
72
83
  write!(f, ", missing result")?;
73
84
  }
@@ -82,7 +93,10 @@ pub mod coresdk {
82
93
  common::v1::Payload,
83
94
  failure::v1::{failure, CanceledFailureInfo, Failure as APIFailure},
84
95
  };
85
- use crate::temporal::api::{enums::v1::TimeoutType, failure::v1::TimeoutFailureInfo};
96
+ use crate::{
97
+ coresdk::activity_result::activity_resolution::Status,
98
+ temporal::api::enums::v1::TimeoutType,
99
+ };
86
100
  use activity_execution_result as aer;
87
101
  use std::fmt::{Display, Formatter};
88
102
 
@@ -125,13 +139,13 @@ pub mod coresdk {
125
139
  write!(f, "ActivityExecutionResult(")?;
126
140
  match self {
127
141
  aer::Status::Completed(v) => {
128
- write!(f, "{})", v)
142
+ write!(f, "{v})")
129
143
  }
130
144
  aer::Status::Failed(v) => {
131
- write!(f, "{})", v)
145
+ write!(f, "{v})")
132
146
  }
133
147
  aer::Status::Cancelled(v) => {
134
- write!(f, "{})", v)
148
+ write!(f, "{v})")
135
149
  }
136
150
  aer::Status::WillCompleteAsync(_) => {
137
151
  write!(f, "Will complete async)")
@@ -144,7 +158,7 @@ pub mod coresdk {
144
158
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
145
159
  write!(f, "Success(")?;
146
160
  if let Some(ref v) = self.result {
147
- write!(f, "{}", v)?;
161
+ write!(f, "{v}")?;
148
162
  }
149
163
  write!(f, ")")
150
164
  }
@@ -154,7 +168,7 @@ pub mod coresdk {
154
168
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
155
169
  write!(f, "Failure(")?;
156
170
  if let Some(ref v) = self.failure {
157
- write!(f, "{}", v)?;
171
+ write!(f, "{v}")?;
158
172
  }
159
173
  write!(f, ")")
160
174
  }
@@ -164,7 +178,7 @@ pub mod coresdk {
164
178
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
165
179
  write!(f, "Cancellation(")?;
166
180
  if let Some(ref v) = self.failure {
167
- write!(f, "{}", v)?;
181
+ write!(f, "{v}")?;
168
182
  }
169
183
  write!(f, ")")
170
184
  }
@@ -185,7 +199,7 @@ pub mod coresdk {
185
199
  pub fn unwrap_ok_payload(self) -> Payload {
186
200
  match self.status.unwrap() {
187
201
  activity_resolution::Status::Completed(c) => c.result.unwrap(),
188
- _ => panic!("Activity was not successful"),
202
+ e => panic!("Activity was not successful: {e:?}"),
189
203
  }
190
204
  }
191
205
 
@@ -197,43 +211,42 @@ pub mod coresdk {
197
211
  matches!(self.status, Some(activity_resolution::Status::Failed(_)))
198
212
  }
199
213
 
200
- pub fn timed_out(&self) -> bool {
201
- matches!(self.status, Some(activity_resolution::Status::Failed(Failure {
202
- failure: Some(ref f)
203
- })) if f.is_timeout()
204
- || f.cause.as_ref().map(|c| c.is_timeout()).unwrap_or_default())
214
+ pub fn timed_out(&self) -> Option<TimeoutType> {
215
+ match self.status {
216
+ Some(activity_resolution::Status::Failed(Failure {
217
+ failure: Some(ref f),
218
+ })) => f
219
+ .is_timeout()
220
+ .or_else(|| f.cause.as_ref().and_then(|c| c.is_timeout())),
221
+ _ => None,
222
+ }
205
223
  }
206
224
 
207
225
  pub fn cancelled(&self) -> bool {
208
226
  matches!(self.status, Some(activity_resolution::Status::Cancelled(_)))
209
227
  }
228
+
229
+ /// If this resolution is any kind of failure, return the inner failure details. Panics
230
+ /// if the activity succeeded, is in backoff, or this resolution is malformed.
231
+ pub fn unwrap_failure(self) -> APIFailure {
232
+ match self.status.unwrap() {
233
+ Status::Failed(f) => f.failure.unwrap(),
234
+ Status::Cancelled(c) => c.failure.unwrap(),
235
+ _ => panic!("Actvity did not fail"),
236
+ }
237
+ }
210
238
  }
211
239
 
212
240
  impl Cancellation {
213
- pub fn from_details(payload: Option<Payload>) -> Self {
241
+ /// Create a cancellation result from some payload. This is to be used when telling Core
242
+ /// that an activity completed as cancelled.
243
+ pub fn from_details(details: Option<Payload>) -> Self {
214
244
  Cancellation {
215
245
  failure: Some(APIFailure {
216
246
  message: "Activity cancelled".to_string(),
217
247
  failure_info: Some(failure::FailureInfo::CanceledFailureInfo(
218
248
  CanceledFailureInfo {
219
- details: payload.map(Into::into),
220
- },
221
- )),
222
- ..Default::default()
223
- }),
224
- }
225
- }
226
- }
227
-
228
- impl Failure {
229
- pub fn timeout(timeout_type: TimeoutType) -> Self {
230
- Failure {
231
- failure: Some(APIFailure {
232
- message: "Activity timed out".to_string(),
233
- failure_info: Some(failure::FailureInfo::TimeoutFailureInfo(
234
- TimeoutFailureInfo {
235
- timeout_type: timeout_type as i32,
236
- last_heartbeat_details: None,
249
+ details: details.map(Into::into),
237
250
  },
238
251
  )),
239
252
  ..Default::default()
@@ -243,36 +256,47 @@ pub mod coresdk {
243
256
  }
244
257
  }
245
258
 
246
- pub mod bridge {
247
- tonic::include_proto!("coresdk.bridge");
248
- }
249
-
250
259
  pub mod common {
251
260
  tonic::include_proto!("coresdk.common");
252
261
  use super::external_data::LocalActivityMarkerData;
253
262
  use crate::{
254
- coresdk::{AsJsonPayloadExt, IntoPayloadsExt},
263
+ coresdk::{
264
+ external_data::PatchedMarkerData, AsJsonPayloadExt, FromJsonPayloadExt,
265
+ IntoPayloadsExt,
266
+ },
255
267
  temporal::api::common::v1::{Payload, Payloads},
268
+ PATCHED_MARKER_DETAILS_KEY,
256
269
  };
257
270
  use std::collections::HashMap;
258
271
 
259
272
  pub fn build_has_change_marker_details(
260
- patch_id: &str,
273
+ patch_id: impl Into<String>,
261
274
  deprecated: bool,
262
- ) -> HashMap<String, Payloads> {
275
+ ) -> anyhow::Result<HashMap<String, Payloads>> {
263
276
  let mut hm = HashMap::new();
264
- hm.insert("patch_id".to_string(), patch_id.as_bytes().into());
265
- let deprecated = deprecated as u8;
266
- hm.insert("deprecated".to_string(), (&[deprecated]).into());
267
- hm
277
+ let encoded = PatchedMarkerData {
278
+ id: patch_id.into(),
279
+ deprecated,
280
+ }
281
+ .as_json_payload()?;
282
+ hm.insert(PATCHED_MARKER_DETAILS_KEY.to_string(), encoded.into());
283
+ Ok(hm)
268
284
  }
269
285
 
270
286
  pub fn decode_change_marker_details(
271
287
  details: &HashMap<String, Payloads>,
272
288
  ) -> Option<(String, bool)> {
273
- let name =
274
- std::str::from_utf8(&details.get("patch_id")?.payloads.first()?.data).ok()?;
275
- let deprecated = *details.get("deprecated")?.payloads.first()?.data.first()? != 0;
289
+ // We used to write change markers with plain bytes, so try to decode if they are
290
+ // json first, then fall back to that.
291
+ if let Some(cd) = details.get(PATCHED_MARKER_DETAILS_KEY) {
292
+ let decoded = PatchedMarkerData::from_json_payload(cd.payloads.first()?).ok()?;
293
+ return Some((decoded.id, decoded.deprecated));
294
+ }
295
+
296
+ let id_entry = details.get("patch_id")?.payloads.first()?;
297
+ let deprecated_entry = details.get("deprecated")?.payloads.first()?;
298
+ let name = std::str::from_utf8(&id_entry.data).ok()?;
299
+ let deprecated = *deprecated_entry.data.first()? != 0;
276
300
  Some((name.to_string(), deprecated))
277
301
  }
278
302
 
@@ -317,7 +341,7 @@ pub mod coresdk {
317
341
  }
318
342
 
319
343
  pub mod external_data {
320
- use prost_types::{Duration, Timestamp};
344
+ use prost_wkt_types::{Duration, Timestamp};
321
345
  use serde::{Deserialize, Deserializer, Serialize, Serializer};
322
346
  tonic::include_proto!("coresdk.external_data");
323
347
 
@@ -396,6 +420,7 @@ pub mod coresdk {
396
420
  },
397
421
  temporal::api::{
398
422
  common::v1::Header,
423
+ enums::v1::WorkflowTaskFailedCause,
399
424
  history::v1::{
400
425
  WorkflowExecutionCancelRequestedEventAttributes,
401
426
  WorkflowExecutionSignaledEventAttributes,
@@ -404,7 +429,7 @@ pub mod coresdk {
404
429
  query::v1::WorkflowQuery,
405
430
  },
406
431
  };
407
- use prost_types::Timestamp;
432
+ use prost_wkt_types::Timestamp;
408
433
  use std::{
409
434
  collections::HashMap,
410
435
  fmt::{Display, Formatter},
@@ -428,6 +453,7 @@ pub mod coresdk {
428
453
  reason: reason as i32,
429
454
  }),
430
455
  )],
456
+ available_internal_flags: vec![],
431
457
  }
432
458
  }
433
459
 
@@ -491,7 +517,18 @@ pub mod coresdk {
491
517
 
492
518
  impl Display for EvictionReason {
493
519
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
494
- write!(f, "{:?}", self)
520
+ write!(f, "{self:?}")
521
+ }
522
+ }
523
+
524
+ impl From<EvictionReason> for WorkflowTaskFailedCause {
525
+ fn from(value: EvictionReason) -> Self {
526
+ match value {
527
+ EvictionReason::Nondeterminism => {
528
+ WorkflowTaskFailedCause::NonDeterministicError
529
+ }
530
+ _ => WorkflowTaskFailedCause::Unspecified,
531
+ }
495
532
  }
496
533
  }
497
534
 
@@ -517,7 +554,7 @@ pub mod coresdk {
517
554
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
518
555
  match &self.variant {
519
556
  None => write!(f, "empty"),
520
- Some(v) => write!(f, "{}", v),
557
+ Some(v) => write!(f, "{v}"),
521
558
  }
522
559
  }
523
560
  }
@@ -640,7 +677,7 @@ pub mod coresdk {
640
677
  }
641
678
 
642
679
  pub mod workflow_completion {
643
- use crate::temporal::api::failure;
680
+ use crate::temporal::api::{enums::v1::WorkflowTaskFailedCause, failure};
644
681
  tonic::include_proto!("coresdk.workflow_completion");
645
682
 
646
683
  impl workflow_activation_completion::Status {
@@ -654,7 +691,10 @@ pub mod coresdk {
654
691
 
655
692
  impl From<failure::v1::Failure> for Failure {
656
693
  fn from(f: failure::v1::Failure) -> Self {
657
- Failure { failure: Some(f) }
694
+ Failure {
695
+ failure: Some(f),
696
+ force_cause: WorkflowTaskFailedCause::Unspecified as i32,
697
+ }
658
698
  }
659
699
  }
660
700
  }
@@ -673,7 +713,7 @@ pub mod coresdk {
673
713
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
674
714
  match &self.variant {
675
715
  None => write!(f, "Empty"),
676
- Some(v) => write!(f, "{}", v),
716
+ Some(v) => write!(f, "{v}"),
677
717
  }
678
718
  }
679
719
  }
@@ -853,7 +893,10 @@ pub mod coresdk {
853
893
 
854
894
  impl From<Vec<WorkflowCommand>> for workflow_completion::Success {
855
895
  fn from(v: Vec<WorkflowCommand>) -> Self {
856
- Self { commands: v }
896
+ Self {
897
+ commands: v,
898
+ used_internal_flags: vec![],
899
+ }
857
900
  }
858
901
  }
859
902
 
@@ -907,6 +950,7 @@ pub mod coresdk {
907
950
  status: Some(workflow_activation_completion::Status::Failed(
908
951
  workflow_completion::Failure {
909
952
  failure: Some(failure),
953
+ force_cause: WorkflowTaskFailedCause::Unspecified as i32,
910
954
  },
911
955
  )),
912
956
  }
@@ -990,6 +1034,12 @@ pub mod coresdk {
990
1034
  }
991
1035
  false
992
1036
  }
1037
+
1038
+ pub fn add_internal_flags(&mut self, patch: u32) {
1039
+ if let Some(workflow_activation_completion::Status::Successful(s)) = &mut self.status {
1040
+ s.used_internal_flags.push(patch);
1041
+ }
1042
+ }
993
1043
  }
994
1044
 
995
1045
  /// Makes converting outgoing lang commands into [WorkflowActivationCompletion]s easier
@@ -1027,7 +1077,7 @@ pub mod coresdk {
1027
1077
  )?;
1028
1078
  match &self.status {
1029
1079
  None => write!(f, "empty")?,
1030
- Some(s) => write!(f, "{}", s)?,
1080
+ Some(s) => write!(f, "{s}")?,
1031
1081
  };
1032
1082
  write!(f, ")")
1033
1083
  }
@@ -1037,12 +1087,12 @@ pub mod coresdk {
1037
1087
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1038
1088
  match self {
1039
1089
  workflow_activation_completion::Status::Successful(
1040
- workflow_completion::Success { commands },
1090
+ workflow_completion::Success { commands, .. },
1041
1091
  ) => {
1042
1092
  write!(f, "Success(")?;
1043
1093
  let mut written = 0;
1044
1094
  for c in commands {
1045
- write!(f, "{} ", c)?;
1095
+ write!(f, "{c} ")?;
1046
1096
  written += 1;
1047
1097
  if written >= 10 && written < commands.len() {
1048
1098
  write!(f, "... {} more", commands.len() - written)?;
@@ -1094,21 +1144,12 @@ pub mod coresdk {
1094
1144
  }
1095
1145
  }
1096
1146
 
1097
- impl From<String> for ActivityType {
1098
- fn from(name: String) -> Self {
1099
- Self { name }
1100
- }
1101
- }
1102
-
1103
- impl From<ActivityType> for String {
1104
- fn from(at: ActivityType) -> Self {
1105
- at.name
1106
- }
1107
- }
1108
-
1109
1147
  impl Failure {
1110
- pub fn is_timeout(&self) -> bool {
1111
- matches!(self.failure_info, Some(FailureInfo::TimeoutFailureInfo(_)))
1148
+ pub fn is_timeout(&self) -> Option<crate::temporal::api::enums::v1::TimeoutType> {
1149
+ match &self.failure_info {
1150
+ Some(FailureInfo::TimeoutFailureInfo(ti)) => Some(ti.timeout_type()),
1151
+ _ => None,
1152
+ }
1112
1153
  }
1113
1154
 
1114
1155
  pub fn application_failure(message: String, non_retryable: bool) -> Self {
@@ -1124,6 +1165,26 @@ pub mod coresdk {
1124
1165
  }
1125
1166
  }
1126
1167
 
1168
+ pub fn application_failure_from_error(ae: anyhow::Error, non_retryable: bool) -> Self {
1169
+ Self {
1170
+ failure_info: Some(FailureInfo::ApplicationFailureInfo(
1171
+ ApplicationFailureInfo {
1172
+ non_retryable,
1173
+ ..Default::default()
1174
+ },
1175
+ )),
1176
+ ..ae.chain()
1177
+ .rfold(None, |cause, e| {
1178
+ Some(Self {
1179
+ message: e.to_string(),
1180
+ cause: cause.map(Box::new),
1181
+ ..Default::default()
1182
+ })
1183
+ })
1184
+ .unwrap_or_default()
1185
+ }
1186
+ }
1187
+
1127
1188
  /// Extracts an ApplicationFailureInfo from a Failure instance if it exists
1128
1189
  pub fn maybe_application_failure(&self) -> Option<&ApplicationFailureInfo> {
1129
1190
  if let Failure {
@@ -1194,7 +1255,7 @@ pub mod coresdk {
1194
1255
 
1195
1256
  impl From<anyhow::Error> for Failure {
1196
1257
  fn from(ae: anyhow::Error) -> Self {
1197
- Failure::application_failure(ae.to_string(), false)
1258
+ Failure::application_failure_from_error(ae, false)
1198
1259
  }
1199
1260
  }
1200
1261
 
@@ -1271,7 +1332,10 @@ pub mod coresdk {
1271
1332
  fn as_json_payload(&self) -> anyhow::Result<Payload> {
1272
1333
  let as_json = serde_json::to_string(self)?;
1273
1334
  let mut metadata = HashMap::new();
1274
- metadata.insert("encoding".to_string(), b"json/plain".to_vec());
1335
+ metadata.insert(
1336
+ ENCODING_PAYLOAD_KEY.to_string(),
1337
+ JSON_ENCODING_VAL.as_bytes().to_vec(),
1338
+ );
1275
1339
  Ok(Payload {
1276
1340
  metadata,
1277
1341
  data: as_json.into_bytes(),
@@ -1287,10 +1351,7 @@ pub mod coresdk {
1287
1351
  T: for<'de> Deserialize<'de>,
1288
1352
  {
1289
1353
  fn from_json_payload(payload: &Payload) -> Result<Self, PayloadDeserializeErr> {
1290
- if !matches!(
1291
- payload.metadata.get("encoding").map(|v| v.as_slice()),
1292
- Some(b"json/plain")
1293
- ) {
1354
+ if !payload.is_json_payload() {
1294
1355
  return Err(PayloadDeserializeErr::DeserializerDoesNotHandle);
1295
1356
  }
1296
1357
  let payload_str = std::str::from_utf8(&payload.data).map_err(anyhow::Error::from)?;
@@ -1550,6 +1611,8 @@ pub mod temporal {
1550
1611
  }
1551
1612
  pub mod common {
1552
1613
  pub mod v1 {
1614
+ use crate::{ENCODING_PAYLOAD_KEY, JSON_ENCODING_VAL};
1615
+ use base64::{prelude::BASE64_STANDARD, Engine};
1553
1616
  use std::{
1554
1617
  collections::HashMap,
1555
1618
  fmt::{Display, Formatter},
@@ -1564,7 +1627,7 @@ pub mod temporal {
1564
1627
  // TODO: Set better encodings, whole data converter deal. Setting anything
1565
1628
  // for now at least makes it show up in the web UI.
1566
1629
  let mut metadata = HashMap::new();
1567
- metadata.insert("encoding".to_string(), b"binary/plain".to_vec());
1630
+ metadata.insert(ENCODING_PAYLOAD_KEY.to_string(), b"binary/plain".to_vec());
1568
1631
  Self {
1569
1632
  metadata,
1570
1633
  data: v.as_ref().to_vec(),
@@ -1577,6 +1640,13 @@ pub mod temporal {
1577
1640
  pub fn as_slice(&self) -> &[u8] {
1578
1641
  self.data.as_slice()
1579
1642
  }
1643
+
1644
+ pub fn is_json_payload(&self) -> bool {
1645
+ self.metadata
1646
+ .get(ENCODING_PAYLOAD_KEY)
1647
+ .map(|v| v.as_slice() == JSON_ENCODING_VAL.as_bytes())
1648
+ .unwrap_or_default()
1649
+ }
1580
1650
  }
1581
1651
 
1582
1652
  impl Display for Payload {
@@ -1586,11 +1656,11 @@ pub mod temporal {
1586
1656
  write!(
1587
1657
  f,
1588
1658
  "[{}..{}]",
1589
- base64::encode(windows.next().unwrap_or_default()),
1590
- base64::encode(windows.next_back().unwrap_or_default())
1659
+ BASE64_STANDARD.encode(windows.next().unwrap_or_default()),
1660
+ BASE64_STANDARD.encode(windows.next_back().unwrap_or_default())
1591
1661
  )
1592
1662
  } else {
1593
- write!(f, "[{}]", base64::encode(&self.data))
1663
+ write!(f, "[{}]", BASE64_STANDARD.encode(&self.data))
1594
1664
  }
1595
1665
  }
1596
1666
  }
@@ -1634,6 +1704,26 @@ pub mod temporal {
1634
1704
  }
1635
1705
  }
1636
1706
  }
1707
+
1708
+ impl From<String> for ActivityType {
1709
+ fn from(name: String) -> Self {
1710
+ Self { name }
1711
+ }
1712
+ }
1713
+
1714
+ impl From<&str> for ActivityType {
1715
+ fn from(name: &str) -> Self {
1716
+ Self {
1717
+ name: name.to_string(),
1718
+ }
1719
+ }
1720
+ }
1721
+
1722
+ impl From<ActivityType> for String {
1723
+ fn from(at: ActivityType) -> Self {
1724
+ at.name
1725
+ }
1726
+ }
1637
1727
  }
1638
1728
  }
1639
1729
  pub mod enums {
@@ -1699,6 +1789,7 @@ pub mod temporal {
1699
1789
  | EventType::TimerCanceled
1700
1790
  | EventType::TimerStarted
1701
1791
  | EventType::UpsertWorkflowSearchAttributes
1792
+ | EventType::WorkflowPropertiesModified
1702
1793
  | EventType::WorkflowExecutionCanceled
1703
1794
  | EventType::WorkflowExecutionCompleted
1704
1795
  | EventType::WorkflowExecutionContinuedAsNew
@@ -1757,6 +1848,15 @@ pub mod temporal {
1757
1848
  _ => false,
1758
1849
  }
1759
1850
  }
1851
+
1852
+ pub fn is_wft_closed_event(&self) -> bool {
1853
+ match self.event_type() {
1854
+ EventType::WorkflowTaskCompleted => true,
1855
+ EventType::WorkflowTaskFailed => true,
1856
+ EventType::WorkflowTaskTimedOut => true,
1857
+ _ => false,
1858
+ }
1859
+ }
1760
1860
  }
1761
1861
 
1762
1862
  impl Display for HistoryEvent {
@@ -1769,6 +1869,60 @@ pub mod temporal {
1769
1869
  )
1770
1870
  }
1771
1871
  }
1872
+
1873
+ impl Attributes {
1874
+ pub fn event_type(&self) -> EventType {
1875
+ // I just absolutely _love_ this
1876
+ match self {
1877
+ Attributes::WorkflowExecutionStartedEventAttributes(_) => {EventType::WorkflowExecutionStarted}
1878
+ Attributes::WorkflowExecutionCompletedEventAttributes(_) => {EventType::WorkflowExecutionCompleted}
1879
+ Attributes::WorkflowExecutionFailedEventAttributes(_) => {EventType::WorkflowExecutionFailed}
1880
+ Attributes::WorkflowExecutionTimedOutEventAttributes(_) => {EventType::WorkflowExecutionTimedOut}
1881
+ Attributes::WorkflowTaskScheduledEventAttributes(_) => {EventType::WorkflowTaskScheduled}
1882
+ Attributes::WorkflowTaskStartedEventAttributes(_) => {EventType::WorkflowTaskStarted}
1883
+ Attributes::WorkflowTaskCompletedEventAttributes(_) => {EventType::WorkflowTaskCompleted}
1884
+ Attributes::WorkflowTaskTimedOutEventAttributes(_) => {EventType::WorkflowTaskTimedOut}
1885
+ Attributes::WorkflowTaskFailedEventAttributes(_) => {EventType::WorkflowTaskFailed}
1886
+ Attributes::ActivityTaskScheduledEventAttributes(_) => {EventType::ActivityTaskScheduled}
1887
+ Attributes::ActivityTaskStartedEventAttributes(_) => {EventType::ActivityTaskStarted}
1888
+ Attributes::ActivityTaskCompletedEventAttributes(_) => {EventType::ActivityTaskCompleted}
1889
+ Attributes::ActivityTaskFailedEventAttributes(_) => {EventType::ActivityTaskFailed}
1890
+ Attributes::ActivityTaskTimedOutEventAttributes(_) => {EventType::ActivityTaskTimedOut}
1891
+ Attributes::TimerStartedEventAttributes(_) => {EventType::TimerStarted}
1892
+ Attributes::TimerFiredEventAttributes(_) => {EventType::TimerFired}
1893
+ Attributes::ActivityTaskCancelRequestedEventAttributes(_) => {EventType::ActivityTaskCancelRequested}
1894
+ Attributes::ActivityTaskCanceledEventAttributes(_) => {EventType::ActivityTaskCanceled}
1895
+ Attributes::TimerCanceledEventAttributes(_) => {EventType::TimerCanceled}
1896
+ Attributes::MarkerRecordedEventAttributes(_) => {EventType::MarkerRecorded}
1897
+ Attributes::WorkflowExecutionSignaledEventAttributes(_) => {EventType::WorkflowExecutionSignaled}
1898
+ Attributes::WorkflowExecutionTerminatedEventAttributes(_) => {EventType::WorkflowExecutionTerminated}
1899
+ Attributes::WorkflowExecutionCancelRequestedEventAttributes(_) => {EventType::WorkflowExecutionCancelRequested}
1900
+ Attributes::WorkflowExecutionCanceledEventAttributes(_) => {EventType::WorkflowExecutionCanceled}
1901
+ Attributes::RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(_) => {EventType::RequestCancelExternalWorkflowExecutionInitiated}
1902
+ Attributes::RequestCancelExternalWorkflowExecutionFailedEventAttributes(_) => {EventType::RequestCancelExternalWorkflowExecutionFailed}
1903
+ Attributes::ExternalWorkflowExecutionCancelRequestedEventAttributes(_) => {EventType::ExternalWorkflowExecutionCancelRequested}
1904
+ Attributes::WorkflowExecutionContinuedAsNewEventAttributes(_) => {EventType::WorkflowExecutionContinuedAsNew}
1905
+ Attributes::StartChildWorkflowExecutionInitiatedEventAttributes(_) => {EventType::StartChildWorkflowExecutionInitiated}
1906
+ Attributes::StartChildWorkflowExecutionFailedEventAttributes(_) => {EventType::StartChildWorkflowExecutionFailed}
1907
+ Attributes::ChildWorkflowExecutionStartedEventAttributes(_) => {EventType::ChildWorkflowExecutionStarted}
1908
+ Attributes::ChildWorkflowExecutionCompletedEventAttributes(_) => {EventType::ChildWorkflowExecutionCompleted}
1909
+ Attributes::ChildWorkflowExecutionFailedEventAttributes(_) => {EventType::ChildWorkflowExecutionFailed}
1910
+ Attributes::ChildWorkflowExecutionCanceledEventAttributes(_) => {EventType::ChildWorkflowExecutionCanceled}
1911
+ Attributes::ChildWorkflowExecutionTimedOutEventAttributes(_) => {EventType::ChildWorkflowExecutionTimedOut}
1912
+ Attributes::ChildWorkflowExecutionTerminatedEventAttributes(_) => {EventType::ChildWorkflowExecutionTerminated}
1913
+ Attributes::SignalExternalWorkflowExecutionInitiatedEventAttributes(_) => {EventType::SignalExternalWorkflowExecutionInitiated}
1914
+ Attributes::SignalExternalWorkflowExecutionFailedEventAttributes(_) => {EventType::SignalExternalWorkflowExecutionFailed}
1915
+ Attributes::ExternalWorkflowExecutionSignaledEventAttributes(_) => {EventType::ExternalWorkflowExecutionSignaled}
1916
+ Attributes::UpsertWorkflowSearchAttributesEventAttributes(_) => {EventType::UpsertWorkflowSearchAttributes}
1917
+ Attributes::WorkflowExecutionUpdateRejectedEventAttributes(_) => {EventType::WorkflowExecutionUpdateRejected}
1918
+ Attributes::WorkflowExecutionUpdateAcceptedEventAttributes(_) => {EventType::WorkflowExecutionUpdateAccepted}
1919
+ Attributes::WorkflowExecutionUpdateCompletedEventAttributes(_) => {EventType::WorkflowExecutionUpdateCompleted}
1920
+ Attributes::WorkflowPropertiesModifiedExternallyEventAttributes(_) => {EventType::WorkflowPropertiesModifiedExternally}
1921
+ Attributes::ActivityPropertiesModifiedExternallyEventAttributes(_) => {EventType::ActivityPropertiesModifiedExternally}
1922
+ Attributes::WorkflowPropertiesModifiedEventAttributes(_) => {EventType::WorkflowPropertiesModified}
1923
+ }
1924
+ }
1925
+ }
1772
1926
  }
1773
1927
  }
1774
1928
  pub mod namespace {
@@ -1781,6 +1935,11 @@ pub mod temporal {
1781
1935
  tonic::include_proto!("temporal.api.operatorservice.v1");
1782
1936
  }
1783
1937
  }
1938
+ pub mod protocol {
1939
+ pub mod v1 {
1940
+ tonic::include_proto!("temporal.api.protocol.v1");
1941
+ }
1942
+ }
1784
1943
  pub mod query {
1785
1944
  pub mod v1 {
1786
1945
  tonic::include_proto!("temporal.api.query.v1");
@@ -1792,10 +1951,16 @@ pub mod temporal {
1792
1951
  }
1793
1952
  }
1794
1953
  pub mod schedule {
1954
+ #[allow(rustdoc::invalid_html_tags)]
1795
1955
  pub mod v1 {
1796
1956
  tonic::include_proto!("temporal.api.schedule.v1");
1797
1957
  }
1798
1958
  }
1959
+ pub mod sdk {
1960
+ pub mod v1 {
1961
+ tonic::include_proto!("temporal.api.sdk.v1");
1962
+ }
1963
+ }
1799
1964
  pub mod taskqueue {
1800
1965
  pub mod v1 {
1801
1966
  use crate::temporal::api::enums::v1::TaskQueueKind;
@@ -1930,3 +2095,23 @@ pub mod grpc {
1930
2095
  }
1931
2096
  }
1932
2097
  }
2098
+
2099
+ #[cfg(test)]
2100
+ mod tests {
2101
+ use crate::temporal::api::failure::v1::Failure;
2102
+ use anyhow::anyhow;
2103
+
2104
+ #[test]
2105
+ fn anyhow_to_failure_conversion() {
2106
+ let no_causes: Failure = anyhow!("no causes").into();
2107
+ assert_eq!(no_causes.cause, None);
2108
+ assert_eq!(no_causes.message, "no causes");
2109
+ let orig = anyhow!("fail 1");
2110
+ let mid = orig.context("fail 2");
2111
+ let top = mid.context("fail 3");
2112
+ let as_fail: Failure = top.into();
2113
+ assert_eq!(as_fail.message, "fail 3");
2114
+ assert_eq!(as_fail.cause.as_ref().unwrap().message, "fail 2");
2115
+ assert_eq!(as_fail.cause.unwrap().cause.unwrap().message, "fail 1");
2116
+ }
2117
+ }