@temporalio/core-bridge 0.14.0 → 0.16.4

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 (75) hide show
  1. package/Cargo.lock +162 -38
  2. package/Cargo.toml +3 -3
  3. package/index.d.ts +14 -1
  4. package/index.node +0 -0
  5. package/package.json +8 -5
  6. package/releases/aarch64-apple-darwin/index.node +0 -0
  7. package/releases/{x86_64-pc-windows-gnu → aarch64-unknown-linux-gnu}/index.node +0 -0
  8. package/releases/x86_64-apple-darwin/index.node +0 -0
  9. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  10. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  11. package/scripts/build.js +77 -34
  12. package/sdk-core/.buildkite/docker/Dockerfile +1 -1
  13. package/sdk-core/Cargo.toml +6 -5
  14. package/sdk-core/fsm/Cargo.toml +1 -1
  15. package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +2 -2
  16. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +8 -9
  17. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +13 -7
  18. package/sdk-core/fsm/rustfsm_trait/Cargo.toml +2 -2
  19. package/sdk-core/fsm/rustfsm_trait/src/lib.rs +1 -1
  20. package/sdk-core/protos/local/workflow_activation.proto +6 -3
  21. package/sdk-core/sdk-core-protos/Cargo.toml +4 -4
  22. package/sdk-core/sdk-core-protos/src/lib.rs +38 -50
  23. package/sdk-core/src/core_tests/activity_tasks.rs +5 -5
  24. package/sdk-core/src/core_tests/child_workflows.rs +55 -29
  25. package/sdk-core/src/core_tests/determinism.rs +19 -9
  26. package/sdk-core/src/core_tests/mod.rs +3 -3
  27. package/sdk-core/src/core_tests/retry.rs +14 -8
  28. package/sdk-core/src/core_tests/workers.rs +1 -1
  29. package/sdk-core/src/core_tests/workflow_tasks.rs +347 -4
  30. package/sdk-core/src/errors.rs +27 -44
  31. package/sdk-core/src/lib.rs +13 -3
  32. package/sdk-core/src/machines/activity_state_machine.rs +44 -5
  33. package/sdk-core/src/machines/child_workflow_state_machine.rs +31 -11
  34. package/sdk-core/src/machines/complete_workflow_state_machine.rs +1 -1
  35. package/sdk-core/src/machines/continue_as_new_workflow_state_machine.rs +1 -1
  36. package/sdk-core/src/machines/mod.rs +18 -23
  37. package/sdk-core/src/machines/patch_state_machine.rs +8 -8
  38. package/sdk-core/src/machines/signal_external_state_machine.rs +22 -1
  39. package/sdk-core/src/machines/timer_state_machine.rs +21 -3
  40. package/sdk-core/src/machines/transition_coverage.rs +3 -3
  41. package/sdk-core/src/machines/workflow_machines.rs +11 -11
  42. package/sdk-core/src/pending_activations.rs +27 -22
  43. package/sdk-core/src/pollers/gateway.rs +15 -7
  44. package/sdk-core/src/pollers/poll_buffer.rs +6 -5
  45. package/sdk-core/src/pollers/retry.rs +153 -120
  46. package/sdk-core/src/prototype_rust_sdk/workflow_context.rs +61 -46
  47. package/sdk-core/src/prototype_rust_sdk/workflow_future.rs +13 -12
  48. package/sdk-core/src/prototype_rust_sdk.rs +17 -23
  49. package/sdk-core/src/telemetry/metrics.rs +2 -4
  50. package/sdk-core/src/telemetry/mod.rs +6 -7
  51. package/sdk-core/src/test_help/canned_histories.rs +17 -93
  52. package/sdk-core/src/test_help/history_builder.rs +61 -2
  53. package/sdk-core/src/test_help/history_info.rs +21 -2
  54. package/sdk-core/src/test_help/mod.rs +26 -34
  55. package/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +246 -138
  56. package/sdk-core/src/worker/activities.rs +46 -45
  57. package/sdk-core/src/worker/config.rs +11 -0
  58. package/sdk-core/src/worker/dispatcher.rs +5 -5
  59. package/sdk-core/src/worker/mod.rs +86 -56
  60. package/sdk-core/src/workflow/driven_workflow.rs +3 -3
  61. package/sdk-core/src/workflow/history_update.rs +1 -1
  62. package/sdk-core/src/workflow/mod.rs +2 -1
  63. package/sdk-core/src/workflow/workflow_tasks/cache_manager.rs +13 -17
  64. package/sdk-core/src/workflow/workflow_tasks/concurrency_manager.rs +10 -18
  65. package/sdk-core/src/workflow/workflow_tasks/mod.rs +72 -57
  66. package/sdk-core/test_utils/Cargo.toml +1 -1
  67. package/sdk-core/test_utils/src/lib.rs +2 -2
  68. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +61 -1
  69. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +2 -2
  70. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +49 -0
  71. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +2 -2
  72. package/sdk-core/tests/integ_tests/workflow_tests.rs +1 -0
  73. package/src/conversions.rs +17 -0
  74. package/src/errors.rs +0 -7
  75. package/src/lib.rs +0 -20
@@ -165,7 +165,7 @@ impl Default for RetryConfig {
165
165
  }
166
166
 
167
167
  impl RetryConfig {
168
- pub(crate) fn poll_retry_policy() -> Self {
168
+ pub(crate) const fn poll_retry_policy() -> Self {
169
169
  Self {
170
170
  initial_interval: Duration::from_millis(200),
171
171
  randomization_factor: 0.2,
@@ -179,7 +179,7 @@ impl RetryConfig {
179
179
 
180
180
  impl From<RetryConfig> for ExponentialBackoff {
181
181
  fn from(c: RetryConfig) -> Self {
182
- ExponentialBackoff {
182
+ Self {
183
183
  current_interval: c.initial_interval,
184
184
  initial_interval: c.initial_interval,
185
185
  randomization_factor: c.randomization_factor,
@@ -269,7 +269,7 @@ impl Interceptor for ServiceCallInterceptor {
269
269
  .parse()
270
270
  .unwrap_or_else(|_| MetadataValue::from_static("")),
271
271
  );
272
- for (k, v) in self.opts.static_headers.iter() {
272
+ for (k, v) in &self.opts.static_headers {
273
273
  if let (Ok(k), Ok(v)) = (MetadataKey::from_str(k), MetadataValue::from_str(v)) {
274
274
  metadata.insert(k, v);
275
275
  }
@@ -355,8 +355,11 @@ pub trait ServerGatewayApis {
355
355
 
356
356
  /// Fetch new workflow tasks from the provided queue. Should block indefinitely if there is no
357
357
  /// work.
358
- async fn poll_workflow_task(&self, task_queue: String)
359
- -> Result<PollWorkflowTaskQueueResponse>;
358
+ async fn poll_workflow_task(
359
+ &self,
360
+ task_queue: String,
361
+ is_sticky: bool,
362
+ ) -> Result<PollWorkflowTaskQueueResponse>;
360
363
 
361
364
  /// Fetch new activity tasks from the provided queue. Should block indefinitely if there is no
362
365
  /// work.
@@ -516,12 +519,17 @@ impl ServerGatewayApis for ServerGateway {
516
519
  async fn poll_workflow_task(
517
520
  &self,
518
521
  task_queue: String,
522
+ is_sticky: bool,
519
523
  ) -> Result<PollWorkflowTaskQueueResponse> {
520
524
  let mut request = PollWorkflowTaskQueueRequest {
521
525
  namespace: self.opts.namespace.clone(),
522
526
  task_queue: Some(TaskQueue {
523
527
  name: task_queue,
524
- kind: TaskQueueKind::Unspecified as i32,
528
+ kind: if is_sticky {
529
+ TaskQueueKind::Sticky
530
+ } else {
531
+ TaskQueueKind::Normal
532
+ } as i32,
525
533
  }),
526
534
  identity: self.opts.identity.clone(),
527
535
  binary_checksum: self.opts.worker_binary_id.clone(),
@@ -894,7 +902,7 @@ mockall::mock! {
894
902
  ) -> impl Future<Output = Result<StartWorkflowExecutionResponse>> + Send + 'b
895
903
  where 'a: 'b, Self: 'b;
896
904
 
897
- fn poll_workflow_task<'a, 'b>(&'a self, task_queue: String)
905
+ fn poll_workflow_task<'a, 'b>(&'a self, task_queue: String, is_sticky: bool)
898
906
  -> impl Future<Output = Result<PollWorkflowTaskQueueResponse>> + Send + 'b
899
907
  where 'a: 'b, Self: 'b;
900
908
 
@@ -152,7 +152,7 @@ where
152
152
 
153
153
  async fn shutdown_box(self: Box<Self>) {
154
154
  let this = *self;
155
- this.shutdown().await
155
+ this.shutdown().await;
156
156
  }
157
157
  }
158
158
 
@@ -192,7 +192,7 @@ impl Poller<PollWorkflowTaskQueueResponse> for WorkflowTaskPoller {
192
192
 
193
193
  async fn shutdown_box(self: Box<Self>) {
194
194
  let this = *self;
195
- this.shutdown().await
195
+ this.shutdown().await;
196
196
  }
197
197
  }
198
198
 
@@ -200,6 +200,7 @@ pub type PollWorkflowTaskBuffer = LongPollBuffer<PollWorkflowTaskQueueResponse>;
200
200
  pub fn new_workflow_task_buffer(
201
201
  sg: Arc<impl ServerGatewayApis + Send + Sync + 'static + ?Sized>,
202
202
  task_queue: String,
203
+ is_sticky: bool,
203
204
  concurrent_pollers: usize,
204
205
  buffer_size: usize,
205
206
  ) -> PollWorkflowTaskBuffer {
@@ -207,7 +208,7 @@ pub fn new_workflow_task_buffer(
207
208
  move || {
208
209
  let sg = sg.clone();
209
210
  let task_queue = task_queue.clone();
210
- async move { sg.poll_workflow_task(task_queue).await }
211
+ async move { sg.poll_workflow_task(task_queue, is_sticky).await }
211
212
  },
212
213
  concurrent_pollers,
213
214
  buffer_size,
@@ -246,7 +247,7 @@ mod tests {
246
247
  mock_gateway
247
248
  .expect_poll_workflow_task()
248
249
  .times(2)
249
- .returning(move |_| {
250
+ .returning(move |_, _| {
250
251
  async {
251
252
  tokio::time::sleep(Duration::from_millis(100)).await;
252
253
  Ok(Default::default())
@@ -255,7 +256,7 @@ mod tests {
255
256
  });
256
257
  let mock_gateway = Arc::new(mock_gateway);
257
258
 
258
- let pb = new_workflow_task_buffer(mock_gateway, "someq".to_string(), 1, 1);
259
+ let pb = new_workflow_task_buffer(mock_gateway, "someq".to_string(), false, 1, 1);
259
260
 
260
261
  // Poll a bunch of times, "interrupting" it each time, we should only actually have polled
261
262
  // once since the poll takes a while
@@ -27,7 +27,7 @@ pub struct RetryGateway<SG> {
27
27
 
28
28
  impl<SG> RetryGateway<SG> {
29
29
  /// Use the provided retry config with the provided gateway
30
- pub fn new(gateway: SG, retry_config: RetryConfig) -> Self {
30
+ pub const fn new(gateway: SG, retry_config: RetryConfig) -> Self {
31
31
  Self {
32
32
  gateway,
33
33
  retry_config,
@@ -36,23 +36,12 @@ impl<SG> RetryGateway<SG> {
36
36
  }
37
37
 
38
38
  impl<SG: ServerGatewayApis + Send + Sync + 'static> RetryGateway<SG> {
39
- async fn call_with_retry<R, F, Fut>(&self, factory: F) -> Result<R>
40
- where
41
- F: Fn() -> Fut + Unpin,
42
- Fut: Future<Output = Result<R>>,
43
- {
44
- self.call_type_with_retry(factory, CallType::Normal).await
45
- }
46
-
47
- async fn long_poll_call_with_retry<R, F, Fut>(&self, factory: F) -> Result<R>
48
- where
49
- F: Fn() -> Fut + Unpin,
50
- Fut: Future<Output = Result<R>>,
51
- {
52
- self.call_type_with_retry(factory, CallType::LongPoll).await
53
- }
54
-
55
- async fn call_type_with_retry<R, F, Fut>(&self, factory: F, ct: CallType) -> Result<R>
39
+ async fn call_with_retry<R, F, Fut>(
40
+ &self,
41
+ factory: F,
42
+ ct: CallType,
43
+ call_name: &'static str,
44
+ ) -> Result<R>
56
45
  where
57
46
  F: Fn() -> Fut + Unpin,
58
47
  Fut: Future<Output = Result<R>>,
@@ -61,10 +50,12 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> RetryGateway<SG> {
61
50
  CallType::Normal => self.retry_config.clone(),
62
51
  CallType::LongPoll => RetryConfig::poll_retry_policy(),
63
52
  };
64
- Ok(FutureRetry::new(factory, TonicErrorHandler::new(rtc, ct))
65
- .await
66
- .map_err(|(e, _attempt)| e)?
67
- .0)
53
+ Ok(
54
+ FutureRetry::new(factory, TonicErrorHandler::new(rtc, ct, call_name))
55
+ .await
56
+ .map_err(|(e, _attempt)| e)?
57
+ .0,
58
+ )
68
59
  }
69
60
  }
70
61
 
@@ -73,17 +64,19 @@ struct TonicErrorHandler {
73
64
  backoff: ExponentialBackoff,
74
65
  max_retries: usize,
75
66
  call_type: CallType,
67
+ call_name: &'static str,
76
68
  }
77
69
  impl TonicErrorHandler {
78
- fn new(cfg: RetryConfig, call_type: CallType) -> Self {
70
+ fn new(cfg: RetryConfig, call_type: CallType, call_name: &'static str) -> Self {
79
71
  Self {
80
72
  max_retries: cfg.max_retries,
81
73
  backoff: cfg.into(),
82
74
  call_type,
75
+ call_name,
83
76
  }
84
77
  }
85
78
 
86
- fn should_log_retry_warning(&self, cur_attempt: usize) -> bool {
79
+ const fn should_log_retry_warning(&self, cur_attempt: usize) -> bool {
87
80
  // Warn on more than 5 retries for unlimited retrying
88
81
  if self.max_retries == 0 && cur_attempt > 5 {
89
82
  return true;
@@ -111,9 +104,9 @@ impl ErrorHandler<tonic::Status> for TonicErrorHandler {
111
104
  }
112
105
 
113
106
  if current_attempt == 1 {
114
- debug!(error=?e, "gRPC call failed on first attempt")
107
+ debug!(error=?e, "gRPC call {} failed on first attempt", self.call_name);
115
108
  } else if self.should_log_retry_warning(current_attempt) {
116
- warn!(error=?e, "gRPC call retried {} times", current_attempt)
109
+ warn!(error=?e, "gRPC call {} retried {} times", self.call_name, current_attempt);
117
110
  }
118
111
 
119
112
  // Long polls are OK with being cancelled or running into the timeout because there's
@@ -140,6 +133,13 @@ impl ErrorHandler<tonic::Status> for TonicErrorHandler {
140
133
  }
141
134
  }
142
135
 
136
+ macro_rules! retry_call {
137
+ ($myself:ident, $ctype:expr, $call_name:ident, $($args:expr),*) => {{
138
+ let fact = move || { $myself.gateway.$call_name($($args,)*)};
139
+ $myself.call_with_retry(fact, $ctype, stringify!($call_name)).await
140
+ }};
141
+ }
142
+
143
143
  #[async_trait::async_trait]
144
144
  impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryGateway<SG> {
145
145
  async fn start_workflow(
@@ -150,33 +150,42 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
150
150
  workflow_type: String,
151
151
  task_timeout: Option<Duration>,
152
152
  ) -> Result<StartWorkflowExecutionResponse> {
153
- let input = &input;
154
- let factory = move || {
155
- self.gateway.start_workflow(
156
- input.to_vec(),
157
- task_queue.clone(),
158
- workflow_id.clone(),
159
- workflow_type.clone(),
160
- task_timeout,
161
- )
162
- };
163
- self.call_with_retry(factory).await
153
+ retry_call!(
154
+ self,
155
+ CallType::Normal,
156
+ start_workflow,
157
+ input.clone(),
158
+ task_queue.clone(),
159
+ workflow_id.clone(),
160
+ workflow_type.clone(),
161
+ task_timeout
162
+ )
164
163
  }
165
164
 
166
165
  async fn poll_workflow_task(
167
166
  &self,
168
167
  task_queue: String,
168
+ is_sticky: bool,
169
169
  ) -> Result<PollWorkflowTaskQueueResponse> {
170
- let factory = move || self.gateway.poll_workflow_task(task_queue.clone());
171
- self.long_poll_call_with_retry(factory).await
170
+ retry_call!(
171
+ self,
172
+ CallType::LongPoll,
173
+ poll_workflow_task,
174
+ task_queue.clone(),
175
+ is_sticky
176
+ )
172
177
  }
173
178
 
174
179
  async fn poll_activity_task(
175
180
  &self,
176
181
  task_queue: String,
177
182
  ) -> Result<PollActivityTaskQueueResponse> {
178
- let factory = move || self.gateway.poll_activity_task(task_queue.clone());
179
- self.long_poll_call_with_retry(factory).await
183
+ retry_call!(
184
+ self,
185
+ CallType::LongPoll,
186
+ poll_activity_task,
187
+ task_queue.clone()
188
+ )
180
189
  }
181
190
 
182
191
  async fn reset_sticky_task_queue(
@@ -184,19 +193,25 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
184
193
  workflow_id: String,
185
194
  run_id: String,
186
195
  ) -> Result<ResetStickyTaskQueueResponse> {
187
- let factory = move || {
188
- self.gateway
189
- .reset_sticky_task_queue(workflow_id.clone(), run_id.clone())
190
- };
191
- self.call_with_retry(factory).await
196
+ retry_call!(
197
+ self,
198
+ CallType::Normal,
199
+ reset_sticky_task_queue,
200
+ workflow_id.clone(),
201
+ run_id.clone()
202
+ )
192
203
  }
193
204
 
194
205
  async fn complete_workflow_task(
195
206
  &self,
196
207
  request: WorkflowTaskCompletion,
197
208
  ) -> Result<RespondWorkflowTaskCompletedResponse> {
198
- let factory = move || self.gateway.complete_workflow_task(request.clone());
199
- self.call_with_retry(factory).await
209
+ retry_call!(
210
+ self,
211
+ CallType::Normal,
212
+ complete_workflow_task,
213
+ request.clone()
214
+ )
200
215
  }
201
216
 
202
217
  async fn complete_activity_task(
@@ -204,11 +219,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
204
219
  task_token: TaskToken,
205
220
  result: Option<Payloads>,
206
221
  ) -> Result<RespondActivityTaskCompletedResponse> {
207
- let factory = move || {
208
- self.gateway
209
- .complete_activity_task(task_token.clone(), result.clone())
210
- };
211
- self.call_with_retry(factory).await
222
+ retry_call!(
223
+ self,
224
+ CallType::Normal,
225
+ complete_activity_task,
226
+ task_token.clone(),
227
+ result.clone()
228
+ )
212
229
  }
213
230
 
214
231
  async fn record_activity_heartbeat(
@@ -216,11 +233,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
216
233
  task_token: TaskToken,
217
234
  details: Option<Payloads>,
218
235
  ) -> Result<RecordActivityTaskHeartbeatResponse> {
219
- let factory = move || {
220
- self.gateway
221
- .record_activity_heartbeat(task_token.clone(), details.clone())
222
- };
223
- self.call_with_retry(factory).await
236
+ retry_call!(
237
+ self,
238
+ CallType::Normal,
239
+ record_activity_heartbeat,
240
+ task_token.clone(),
241
+ details.clone()
242
+ )
224
243
  }
225
244
 
226
245
  async fn cancel_activity_task(
@@ -228,11 +247,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
228
247
  task_token: TaskToken,
229
248
  details: Option<Payloads>,
230
249
  ) -> Result<RespondActivityTaskCanceledResponse> {
231
- let factory = move || {
232
- self.gateway
233
- .cancel_activity_task(task_token.clone(), details.clone())
234
- };
235
- self.call_with_retry(factory).await
250
+ retry_call!(
251
+ self,
252
+ CallType::Normal,
253
+ cancel_activity_task,
254
+ task_token.clone(),
255
+ details.clone()
256
+ )
236
257
  }
237
258
 
238
259
  async fn fail_activity_task(
@@ -240,11 +261,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
240
261
  task_token: TaskToken,
241
262
  failure: Option<Failure>,
242
263
  ) -> Result<RespondActivityTaskFailedResponse> {
243
- let factory = move || {
244
- self.gateway
245
- .fail_activity_task(task_token.clone(), failure.clone())
246
- };
247
- self.call_with_retry(factory).await
264
+ retry_call!(
265
+ self,
266
+ CallType::Normal,
267
+ fail_activity_task,
268
+ task_token.clone(),
269
+ failure.clone()
270
+ )
248
271
  }
249
272
 
250
273
  async fn fail_workflow_task(
@@ -253,11 +276,14 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
253
276
  cause: WorkflowTaskFailedCause,
254
277
  failure: Option<Failure>,
255
278
  ) -> Result<RespondWorkflowTaskFailedResponse> {
256
- let factory = move || {
257
- self.gateway
258
- .fail_workflow_task(task_token.clone(), cause, failure.clone())
259
- };
260
- self.call_with_retry(factory).await
279
+ retry_call!(
280
+ self,
281
+ CallType::Normal,
282
+ fail_workflow_task,
283
+ task_token.clone(),
284
+ cause,
285
+ failure.clone()
286
+ )
261
287
  }
262
288
 
263
289
  async fn signal_workflow_execution(
@@ -267,15 +293,15 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
267
293
  signal_name: String,
268
294
  payloads: Option<Payloads>,
269
295
  ) -> Result<SignalWorkflowExecutionResponse> {
270
- let factory = move || {
271
- self.gateway.signal_workflow_execution(
272
- workflow_id.clone(),
273
- run_id.clone(),
274
- signal_name.clone(),
275
- payloads.clone(),
276
- )
277
- };
278
- self.call_with_retry(factory).await
296
+ retry_call!(
297
+ self,
298
+ CallType::Normal,
299
+ signal_workflow_execution,
300
+ workflow_id.clone(),
301
+ run_id.clone(),
302
+ signal_name.clone(),
303
+ payloads.clone()
304
+ )
279
305
  }
280
306
 
281
307
  async fn query_workflow_execution(
@@ -284,14 +310,14 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
284
310
  run_id: String,
285
311
  query: WorkflowQuery,
286
312
  ) -> Result<QueryWorkflowResponse> {
287
- let factory = move || {
288
- self.gateway.query_workflow_execution(
289
- workflow_id.clone(),
290
- run_id.clone(),
291
- query.clone(),
292
- )
293
- };
294
- self.call_with_retry(factory).await
313
+ retry_call!(
314
+ self,
315
+ CallType::Normal,
316
+ query_workflow_execution,
317
+ workflow_id.clone(),
318
+ run_id.clone(),
319
+ query.clone()
320
+ )
295
321
  }
296
322
 
297
323
  async fn describe_workflow_execution(
@@ -299,11 +325,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
299
325
  workflow_id: String,
300
326
  run_id: Option<String>,
301
327
  ) -> Result<DescribeWorkflowExecutionResponse> {
302
- let factory = move || {
303
- self.gateway
304
- .describe_workflow_execution(workflow_id.clone(), run_id.clone())
305
- };
306
- self.call_with_retry(factory).await
328
+ retry_call!(
329
+ self,
330
+ CallType::Normal,
331
+ describe_workflow_execution,
332
+ workflow_id.clone(),
333
+ run_id.clone()
334
+ )
307
335
  }
308
336
 
309
337
  async fn get_workflow_execution_history(
@@ -312,14 +340,14 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
312
340
  run_id: Option<String>,
313
341
  page_token: Vec<u8>,
314
342
  ) -> Result<GetWorkflowExecutionHistoryResponse> {
315
- let factory = move || {
316
- self.gateway.get_workflow_execution_history(
317
- workflow_id.clone(),
318
- run_id.clone(),
319
- page_token.clone(),
320
- )
321
- };
322
- self.call_with_retry(factory).await
343
+ retry_call!(
344
+ self,
345
+ CallType::Normal,
346
+ get_workflow_execution_history,
347
+ workflow_id.clone(),
348
+ run_id.clone(),
349
+ page_token.clone()
350
+ )
323
351
  }
324
352
 
325
353
  async fn respond_legacy_query(
@@ -327,11 +355,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
327
355
  task_token: TaskToken,
328
356
  query_result: QueryResult,
329
357
  ) -> Result<RespondQueryTaskCompletedResponse> {
330
- let factory = move || {
331
- self.gateway
332
- .respond_legacy_query(task_token.clone(), query_result.clone())
333
- };
334
- self.call_with_retry(factory).await
358
+ retry_call!(
359
+ self,
360
+ CallType::Normal,
361
+ respond_legacy_query,
362
+ task_token.clone(),
363
+ query_result.clone()
364
+ )
335
365
  }
336
366
 
337
367
  async fn cancel_workflow_execution(
@@ -339,11 +369,13 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
339
369
  workflow_id: String,
340
370
  run_id: Option<String>,
341
371
  ) -> Result<RequestCancelWorkflowExecutionResponse> {
342
- let factory = move || {
343
- self.gateway
344
- .cancel_workflow_execution(workflow_id.clone(), run_id.clone())
345
- };
346
- self.call_with_retry(factory).await
372
+ retry_call!(
373
+ self,
374
+ CallType::Normal,
375
+ cancel_workflow_execution,
376
+ workflow_id.clone(),
377
+ run_id.clone()
378
+ )
347
379
  }
348
380
 
349
381
  async fn terminate_workflow_execution(
@@ -351,15 +383,16 @@ impl<SG: ServerGatewayApis + Send + Sync + 'static> ServerGatewayApis for RetryG
351
383
  workflow_id: String,
352
384
  run_id: Option<String>,
353
385
  ) -> Result<TerminateWorkflowExecutionResponse> {
354
- let factory = move || {
355
- self.gateway
356
- .terminate_workflow_execution(workflow_id.clone(), run_id.clone())
357
- };
358
- self.call_with_retry(factory).await
386
+ retry_call!(
387
+ self,
388
+ CallType::Normal,
389
+ terminate_workflow_execution,
390
+ workflow_id.clone(),
391
+ run_id.clone()
392
+ )
359
393
  }
360
394
 
361
395
  async fn list_namespaces(&self) -> Result<ListNamespacesResponse> {
362
- let factory = move || self.gateway.list_namespaces();
363
- self.call_with_retry(factory).await
396
+ retry_call!(self, CallType::Normal, list_namespaces,)
364
397
  }
365
398
  }