@temporalio/core-bridge 1.11.6 → 1.11.8

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 (191) hide show
  1. package/Cargo.lock +902 -468
  2. package/package.json +3 -3
  3. package/releases/aarch64-apple-darwin/index.node +0 -0
  4. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  5. package/releases/x86_64-apple-darwin/index.node +0 -0
  6. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  7. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  8. package/sdk-core/.cargo/config.toml +5 -0
  9. package/sdk-core/.github/workflows/per-pr.yml +59 -5
  10. package/sdk-core/Cargo.toml +3 -2
  11. package/sdk-core/client/Cargo.toml +3 -3
  12. package/sdk-core/client/src/lib.rs +154 -161
  13. package/sdk-core/client/src/metrics.rs +15 -8
  14. package/sdk-core/client/src/proxy.rs +1 -1
  15. package/sdk-core/client/src/raw.rs +176 -33
  16. package/sdk-core/client/src/retry.rs +102 -465
  17. package/sdk-core/client/src/worker_registry/mod.rs +2 -2
  18. package/sdk-core/client/src/workflow_handle/mod.rs +19 -1
  19. package/sdk-core/core/Cargo.toml +12 -14
  20. package/sdk-core/core/benches/workflow_replay.rs +1 -1
  21. package/sdk-core/core/src/abstractions.rs +2 -2
  22. package/sdk-core/core/src/core_tests/activity_tasks.rs +99 -46
  23. package/sdk-core/core/src/core_tests/child_workflows.rs +68 -9
  24. package/sdk-core/core/src/core_tests/determinism.rs +2 -2
  25. package/sdk-core/core/src/core_tests/local_activities.rs +20 -33
  26. package/sdk-core/core/src/core_tests/mod.rs +7 -8
  27. package/sdk-core/core/src/core_tests/queries.rs +79 -79
  28. package/sdk-core/core/src/core_tests/replay_flag.rs +5 -5
  29. package/sdk-core/core/src/core_tests/updates.rs +6 -6
  30. package/sdk-core/core/src/core_tests/workers.rs +19 -22
  31. package/sdk-core/core/src/core_tests/workflow_cancels.rs +3 -3
  32. package/sdk-core/core/src/core_tests/workflow_tasks.rs +154 -106
  33. package/sdk-core/core/src/ephemeral_server/mod.rs +66 -10
  34. package/sdk-core/core/src/internal_flags.rs +103 -12
  35. package/sdk-core/core/src/lib.rs +21 -13
  36. package/sdk-core/core/src/pollers/mod.rs +200 -6
  37. package/sdk-core/core/src/pollers/poll_buffer.rs +32 -8
  38. package/sdk-core/core/src/protosext/mod.rs +7 -7
  39. package/sdk-core/core/src/protosext/protocol_messages.rs +2 -2
  40. package/sdk-core/core/src/replay/mod.rs +8 -9
  41. package/sdk-core/core/src/retry_logic.rs +8 -6
  42. package/sdk-core/core/src/telemetry/log_export.rs +4 -4
  43. package/sdk-core/core/src/telemetry/metrics.rs +111 -25
  44. package/sdk-core/core/src/telemetry/mod.rs +11 -4
  45. package/sdk-core/core/src/telemetry/otel.rs +108 -144
  46. package/sdk-core/core/src/telemetry/prometheus_server.rs +1 -4
  47. package/sdk-core/core/src/test_help/mod.rs +27 -21
  48. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -5
  49. package/sdk-core/core/src/worker/activities/local_activities.rs +9 -9
  50. package/sdk-core/core/src/worker/activities.rs +34 -46
  51. package/sdk-core/core/src/worker/client/mocks.rs +24 -2
  52. package/sdk-core/core/src/worker/client.rs +169 -33
  53. package/sdk-core/core/src/worker/mod.rs +132 -56
  54. package/sdk-core/core/src/worker/nexus.rs +410 -0
  55. package/sdk-core/core/src/worker/tuner/resource_based.rs +27 -5
  56. package/sdk-core/core/src/worker/tuner.rs +29 -2
  57. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +8 -3
  58. package/sdk-core/core/src/worker/workflow/history_update.rs +5 -8
  59. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +83 -87
  60. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +38 -38
  61. package/sdk-core/core/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +117 -0
  62. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +8 -18
  63. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +114 -108
  64. package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +16 -31
  65. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -14
  66. package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +8 -15
  67. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +34 -75
  68. package/sdk-core/core/src/worker/workflow/machines/mod.rs +26 -48
  69. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +10 -17
  70. package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +543 -0
  71. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +22 -31
  72. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +53 -51
  73. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +40 -45
  74. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
  75. package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +8 -10
  76. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +24 -30
  77. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +182 -116
  78. package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +4 -8
  79. package/sdk-core/core/src/worker/workflow/managed_run.rs +75 -45
  80. package/sdk-core/core/src/worker/workflow/mod.rs +104 -55
  81. package/sdk-core/core/src/worker/workflow/run_cache.rs +23 -4
  82. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +4 -4
  83. package/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -3
  84. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +32 -13
  85. package/sdk-core/core-api/Cargo.toml +2 -3
  86. package/sdk-core/core-api/src/errors.rs +22 -20
  87. package/sdk-core/core-api/src/lib.rs +24 -5
  88. package/sdk-core/core-api/src/telemetry/metrics.rs +27 -1
  89. package/sdk-core/core-api/src/telemetry.rs +37 -3
  90. package/sdk-core/core-api/src/worker.rs +36 -3
  91. package/sdk-core/docker/docker-compose-ci.yaml +25 -0
  92. package/sdk-core/etc/otel-collector-ci.yaml +36 -0
  93. package/sdk-core/etc/otel-collector-config.yaml +3 -3
  94. package/sdk-core/etc/prometheus.yaml +1 -1
  95. package/sdk-core/fsm/Cargo.toml +1 -1
  96. package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
  97. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +3 -4
  98. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
  99. package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
  100. package/sdk-core/sdk/Cargo.toml +1 -2
  101. package/sdk-core/sdk/src/activity_context.rs +1 -1
  102. package/sdk-core/sdk/src/interceptors.rs +1 -1
  103. package/sdk-core/sdk/src/lib.rs +126 -54
  104. package/sdk-core/sdk/src/workflow_context/options.rs +184 -74
  105. package/sdk-core/sdk/src/workflow_context.rs +193 -79
  106. package/sdk-core/sdk/src/workflow_future.rs +151 -131
  107. package/sdk-core/sdk-core-protos/Cargo.toml +3 -4
  108. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -1
  109. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +46 -0
  110. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +254 -5
  111. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +108 -2
  112. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +94 -15
  113. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +102 -4
  114. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +84 -0
  115. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +25 -10
  116. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +14 -1
  117. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +25 -0
  118. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +41 -0
  119. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +59 -0
  120. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +2 -0
  121. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +135 -0
  122. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/push-to-buf.yml +20 -0
  123. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +13 -0
  124. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +13 -0
  125. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +13 -21
  126. package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +2 -2
  127. package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
  128. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3386 -1047
  129. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +3529 -1144
  130. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +39 -1
  131. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -0
  132. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +39 -1
  133. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +252 -0
  134. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +1 -0
  135. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +6 -0
  136. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +96 -0
  137. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +2 -0
  138. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
  139. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/nexus.proto +42 -0
  140. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -0
  141. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +43 -2
  142. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +13 -1
  143. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +14 -0
  144. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +70 -12
  145. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +12 -0
  146. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/query/v1/message.proto +9 -2
  147. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -2
  148. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +206 -0
  149. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +482 -97
  150. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +230 -43
  151. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +6 -0
  152. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/nexus/nexus.proto +71 -0
  153. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +46 -2
  154. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +55 -9
  155. package/sdk-core/sdk-core-protos/src/history_builder.rs +5 -5
  156. package/sdk-core/sdk-core-protos/src/history_info.rs +5 -6
  157. package/sdk-core/sdk-core-protos/src/lib.rs +414 -34
  158. package/sdk-core/sdk-core-protos/src/task_token.rs +1 -1
  159. package/sdk-core/test-utils/Cargo.toml +3 -11
  160. package/sdk-core/test-utils/src/canned_histories.rs +1 -1
  161. package/sdk-core/test-utils/src/lib.rs +159 -85
  162. package/sdk-core/tests/fuzzy_workflow.rs +3 -3
  163. package/sdk-core/tests/heavy_tests.rs +3 -3
  164. package/sdk-core/tests/integ_tests/client_tests.rs +171 -20
  165. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +45 -39
  166. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +7 -6
  167. package/sdk-core/tests/integ_tests/metrics_tests.rs +492 -35
  168. package/sdk-core/tests/integ_tests/polling_tests.rs +7 -5
  169. package/sdk-core/tests/integ_tests/queries_tests.rs +14 -17
  170. package/sdk-core/tests/integ_tests/update_tests.rs +47 -44
  171. package/sdk-core/tests/integ_tests/visibility_tests.rs +4 -3
  172. package/sdk-core/tests/integ_tests/worker_tests.rs +5 -5
  173. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +15 -13
  174. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +28 -14
  175. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +7 -1
  176. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +57 -4
  177. package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
  178. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +24 -18
  179. package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +506 -0
  180. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +1 -1
  181. package/sdk-core/tests/integ_tests/workflow_tests/priority.rs +104 -0
  182. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +34 -31
  183. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
  184. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -7
  185. package/sdk-core/tests/integ_tests/workflow_tests.rs +152 -116
  186. package/sdk-core/tests/main.rs +36 -6
  187. package/sdk-core/tests/runner.rs +30 -9
  188. package/src/conversions/slot_supplier_bridge.rs +4 -0
  189. package/src/conversions.rs +1 -0
  190. package/src/worker.rs +5 -7
  191. package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -78
@@ -13,8 +13,8 @@ mod task_token;
13
13
 
14
14
  #[cfg(feature = "history_builders")]
15
15
  pub use history_builder::{
16
- default_act_sched, default_wes_attribs, TestHistoryBuilder, DEFAULT_ACTIVITY_TYPE,
17
- DEFAULT_WORKFLOW_TYPE,
16
+ DEFAULT_ACTIVITY_TYPE, DEFAULT_WORKFLOW_TYPE, TestHistoryBuilder, default_act_sched,
17
+ default_wes_attribs,
18
18
  };
19
19
  #[cfg(feature = "history_builders")]
20
20
  pub use history_info::HistoryInfo;
@@ -37,13 +37,16 @@ pub mod coresdk {
37
37
  tonic::include_proto!("coresdk");
38
38
 
39
39
  use crate::{
40
+ ENCODING_PAYLOAD_KEY, JSON_ENCODING_VAL,
40
41
  temporal::api::{
41
42
  common::v1::{Payload, Payloads, WorkflowExecution},
42
- enums::v1::WorkflowTaskFailedCause,
43
- failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
43
+ enums::v1::{TimeoutType, WorkflowTaskFailedCause},
44
+ failure::v1::{
45
+ ActivityFailureInfo, ApplicationFailureInfo, Failure, TimeoutFailureInfo,
46
+ failure::FailureInfo,
47
+ },
44
48
  workflowservice::v1::PollActivityTaskQueueResponse,
45
49
  },
46
- ENCODING_PAYLOAD_KEY, JSON_ENCODING_VAL,
47
50
  };
48
51
  use activity_task::ActivityTask;
49
52
  use serde::{Deserialize, Serialize};
@@ -53,9 +56,9 @@ pub mod coresdk {
53
56
  fmt::{Display, Formatter},
54
57
  iter::FromIterator,
55
58
  };
56
- use workflow_activation::{workflow_activation_job, WorkflowActivationJob};
57
- use workflow_commands::{workflow_command, workflow_command::Variant, WorkflowCommand};
58
- use workflow_completion::{workflow_activation_completion, WorkflowActivationCompletion};
59
+ use workflow_activation::{WorkflowActivationJob, workflow_activation_job};
60
+ use workflow_commands::{WorkflowCommand, workflow_command, workflow_command::Variant};
61
+ use workflow_completion::{WorkflowActivationCompletion, workflow_activation_completion};
59
62
 
60
63
  #[allow(clippy::module_inception)]
61
64
  pub mod activity_task {
@@ -104,7 +107,7 @@ pub mod coresdk {
104
107
  tonic::include_proto!("coresdk.activity_result");
105
108
  use super::super::temporal::api::{
106
109
  common::v1::Payload,
107
- failure::v1::{failure, CanceledFailureInfo, Failure as APIFailure},
110
+ failure::v1::{CanceledFailureInfo, Failure as APIFailure, failure},
108
111
  };
109
112
  use crate::{
110
113
  coresdk::activity_result::activity_resolution::Status,
@@ -284,12 +287,12 @@ pub mod coresdk {
284
287
  tonic::include_proto!("coresdk.common");
285
288
  use super::external_data::LocalActivityMarkerData;
286
289
  use crate::{
290
+ PATCHED_MARKER_DETAILS_KEY,
287
291
  coresdk::{
288
- external_data::PatchedMarkerData, AsJsonPayloadExt, FromJsonPayloadExt,
289
- IntoPayloadsExt,
292
+ AsJsonPayloadExt, FromJsonPayloadExt, IntoPayloadsExt,
293
+ external_data::PatchedMarkerData,
290
294
  },
291
295
  temporal::api::common::v1::{Payload, Payloads},
292
- PATCHED_MARKER_DETAILS_KEY,
293
296
  };
294
297
  use std::collections::HashMap;
295
298
 
@@ -447,10 +450,10 @@ pub mod coresdk {
447
450
  pub mod workflow_activation {
448
451
  use crate::{
449
452
  coresdk::{
450
- activity_result::{activity_resolution, ActivityResolution},
453
+ FromPayloadsExt,
454
+ activity_result::{ActivityResolution, activity_resolution},
451
455
  common::NamespacedWorkflowExecution,
452
456
  workflow_activation::remove_from_cache::EvictionReason,
453
- FromPayloadsExt,
454
457
  },
455
458
  temporal::api::{
456
459
  enums::v1::WorkflowTaskFailedCause,
@@ -602,7 +605,7 @@ pub mod coresdk {
602
605
  r.seq,
603
606
  r.result
604
607
  .as_ref()
605
- .unwrap_or_else(|| &ActivityResolution { status: None })
608
+ .unwrap_or(&ActivityResolution { status: None })
606
609
  )
607
610
  }
608
611
  workflow_activation_job::Variant::NotifyHasPatch(_) => {
@@ -626,6 +629,12 @@ pub mod coresdk {
626
629
  workflow_activation_job::Variant::DoUpdate(_) => {
627
630
  write!(f, "DoUpdate")
628
631
  }
632
+ workflow_activation_job::Variant::ResolveNexusOperationStart(_) => {
633
+ write!(f, "ResolveNexusOperationStart")
634
+ }
635
+ workflow_activation_job::Variant::ResolveNexusOperation(_) => {
636
+ write!(f, "ResolveNexusOperation")
637
+ }
629
638
  }
630
639
  }
631
640
  }
@@ -674,8 +683,8 @@ pub mod coresdk {
674
683
  }
675
684
 
676
685
  impl From<WorkflowExecutionCancelRequestedEventAttributes> for CancelWorkflow {
677
- fn from(_a: WorkflowExecutionCancelRequestedEventAttributes) -> Self {
678
- Self { details: vec![] }
686
+ fn from(a: WorkflowExecutionCancelRequestedEventAttributes) -> Self {
687
+ Self { reason: a.cause }
679
688
  }
680
689
  }
681
690
 
@@ -716,6 +725,7 @@ pub mod coresdk {
716
725
  memo: attrs.memo,
717
726
  search_attributes: attrs.search_attributes,
718
727
  start_time: Some(start_time),
728
+ root_workflow: attrs.root_workflow_execution,
719
729
  }
720
730
  }
721
731
  }
@@ -747,6 +757,50 @@ pub mod coresdk {
747
757
  tonic::include_proto!("coresdk.child_workflow");
748
758
  }
749
759
 
760
+ pub mod nexus {
761
+ use crate::temporal::api::workflowservice::v1::PollNexusTaskQueueResponse;
762
+ use std::fmt::{Display, Formatter};
763
+
764
+ tonic::include_proto!("coresdk.nexus");
765
+
766
+ impl NexusTask {
767
+ /// Unwrap the inner server-delivered nexus task if that's what this is, else panic.
768
+ pub fn unwrap_task(self) -> PollNexusTaskQueueResponse {
769
+ if let Some(nexus_task::Variant::Task(t)) = self.variant {
770
+ return t;
771
+ }
772
+ panic!("Nexus task did not contain a server task");
773
+ }
774
+
775
+ /// Get the task token
776
+ pub fn task_token(&self) -> &[u8] {
777
+ match &self.variant {
778
+ Some(nexus_task::Variant::Task(t)) => t.task_token.as_slice(),
779
+ Some(nexus_task::Variant::CancelTask(c)) => c.task_token.as_slice(),
780
+ None => panic!("Nexus task did not contain a task token"),
781
+ }
782
+ }
783
+ }
784
+
785
+ impl Display for nexus_task_completion::Status {
786
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
787
+ write!(f, "NexusTaskCompletion(")?;
788
+ match self {
789
+ nexus_task_completion::Status::Completed(c) => {
790
+ write!(f, "{c}")
791
+ }
792
+ nexus_task_completion::Status::Error(e) => {
793
+ write!(f, "{e}")
794
+ }
795
+ nexus_task_completion::Status::AckCancel(_) => {
796
+ write!(f, "AckCancel")
797
+ }
798
+ }?;
799
+ write!(f, ")")
800
+ }
801
+ }
802
+ }
803
+
750
804
  pub mod workflow_commands {
751
805
  tonic::include_proto!("coresdk.workflow_commands");
752
806
 
@@ -906,6 +960,18 @@ pub mod coresdk {
906
960
  }
907
961
  }
908
962
 
963
+ impl Display for ScheduleNexusOperation {
964
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
965
+ write!(f, "ScheduleNexusOperation({})", self.seq)
966
+ }
967
+ }
968
+
969
+ impl Display for RequestCancelNexusOperation {
970
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
971
+ write!(f, "RequestCancelNexusOperation({})", self.seq)
972
+ }
973
+ }
974
+
909
975
  impl QueryResult {
910
976
  /// Helper to construct the Temporal API query result types.
911
977
  pub fn into_components(self) -> (String, QueryResultType, Option<Payloads>, String) {
@@ -956,16 +1022,16 @@ pub mod coresdk {
956
1022
 
957
1023
  impl From<workflow_command::Variant> for WorkflowCommand {
958
1024
  fn from(v: workflow_command::Variant) -> Self {
959
- Self { variant: Some(v) }
1025
+ Self {
1026
+ variant: Some(v),
1027
+ user_metadata: None,
1028
+ }
960
1029
  }
961
1030
  }
962
1031
 
963
1032
  impl workflow_completion::Success {
964
1033
  pub fn from_variants(cmds: Vec<Variant>) -> Self {
965
- let cmds: Vec<_> = cmds
966
- .into_iter()
967
- .map(|c| WorkflowCommand { variant: Some(c) })
968
- .collect();
1034
+ let cmds: Vec<_> = cmds.into_iter().map(|c| c.into()).collect();
969
1035
  cmds.into()
970
1036
  }
971
1037
  }
@@ -980,7 +1046,7 @@ pub mod coresdk {
980
1046
  }
981
1047
  }
982
1048
 
983
- /// Create a successful activation from a list of commands
1049
+ /// Create a successful activation from a list of command variants
984
1050
  pub fn from_cmds(run_id: impl Into<String>, cmds: Vec<workflow_command::Variant>) -> Self {
985
1051
  let success = workflow_completion::Success::from_variants(cmds);
986
1052
  Self {
@@ -989,7 +1055,7 @@ pub mod coresdk {
989
1055
  }
990
1056
  }
991
1057
 
992
- /// Create a successful activation from just one command
1058
+ /// Create a successful activation from just one command variant
993
1059
  pub fn from_cmd(run_id: impl Into<String>, cmd: workflow_command::Variant) -> Self {
994
1060
  let success = workflow_completion::Success::from_variants(vec![cmd]);
995
1061
  Self {
@@ -1031,6 +1097,7 @@ pub mod coresdk {
1031
1097
  wfc,
1032
1098
  WorkflowCommand {
1033
1099
  variant: Some(workflow_command::Variant::FailWorkflowExecution(_)),
1100
+ ..
1034
1101
  }
1035
1102
  )
1036
1103
  });
@@ -1046,6 +1113,7 @@ pub mod coresdk {
1046
1113
  wfc,
1047
1114
  WorkflowCommand {
1048
1115
  variant: Some(workflow_command::Variant::CancelWorkflowExecution(_)),
1116
+ ..
1049
1117
  }
1050
1118
  )
1051
1119
  });
@@ -1063,6 +1131,7 @@ pub mod coresdk {
1063
1131
  variant: Some(
1064
1132
  workflow_command::Variant::ContinueAsNewWorkflowExecution(_)
1065
1133
  ),
1134
+ ..
1066
1135
  }
1067
1136
  )
1068
1137
  });
@@ -1078,7 +1147,8 @@ pub mod coresdk {
1078
1147
  wfc,
1079
1148
  WorkflowCommand {
1080
1149
  variant: Some(workflow_command::Variant::CompleteWorkflowExecution(_)),
1081
- }
1150
+ ..
1151
+ },
1082
1152
  )
1083
1153
  });
1084
1154
  }
@@ -1194,7 +1264,7 @@ pub mod coresdk {
1194
1264
  schedule_to_close_timeout: r.schedule_to_close_timeout,
1195
1265
  start_to_close_timeout: r.start_to_close_timeout,
1196
1266
  heartbeat_timeout: r.heartbeat_timeout,
1197
- retry_policy: r.retry_policy.map(Into::into),
1267
+ retry_policy: r.retry_policy,
1198
1268
  is_local: false,
1199
1269
  },
1200
1270
  )),
@@ -1243,6 +1313,24 @@ pub mod coresdk {
1243
1313
  }
1244
1314
  }
1245
1315
 
1316
+ pub fn timeout(timeout_type: TimeoutType) -> Self {
1317
+ Self {
1318
+ message: "Activity timed out".to_string(),
1319
+ cause: Some(Box::new(Failure {
1320
+ message: "Activity timed out".to_string(),
1321
+ failure_info: Some(FailureInfo::TimeoutFailureInfo(TimeoutFailureInfo {
1322
+ timeout_type: timeout_type.into(),
1323
+ ..Default::default()
1324
+ })),
1325
+ ..Default::default()
1326
+ })),
1327
+ failure_info: Some(FailureInfo::ActivityFailureInfo(
1328
+ ActivityFailureInfo::default(),
1329
+ )),
1330
+ ..Default::default()
1331
+ }
1332
+ }
1333
+
1246
1334
  /// Extracts an ApplicationFailureInfo from a Failure instance if it exists
1247
1335
  pub fn maybe_application_failure(&self) -> Option<&ApplicationFailureInfo> {
1248
1336
  if let Failure {
@@ -1301,6 +1389,9 @@ pub mod coresdk {
1301
1389
  v.scheduled_event_id
1302
1390
  )?;
1303
1391
  }
1392
+ Some(FailureInfo::NexusHandlerFailureInfo(v)) => {
1393
+ write!(f, "Nexus Handler Failure: {}", v.r#type)?;
1394
+ }
1304
1395
  }
1305
1396
  write!(f, ")")
1306
1397
  }
@@ -1334,7 +1425,7 @@ pub mod coresdk {
1334
1425
  fn from_payloads(p: Option<Payloads>) -> Self {
1335
1426
  match p {
1336
1427
  None => std::iter::empty().collect(),
1337
- Some(p) => p.payloads.into_iter().map(Into::into).collect(),
1428
+ Some(p) => p.payloads.into_iter().collect(),
1338
1429
  }
1339
1430
  }
1340
1431
  }
@@ -1352,7 +1443,7 @@ pub mod coresdk {
1352
1443
  None
1353
1444
  } else {
1354
1445
  Some(Payloads {
1355
- payloads: iterd.map(Into::into).collect(),
1446
+ payloads: iterd.collect(),
1356
1447
  })
1357
1448
  }
1358
1449
  }
@@ -1473,7 +1564,7 @@ pub mod temporal {
1473
1564
  tonic::include_proto!("temporal.api.command.v1");
1474
1565
 
1475
1566
  use crate::{
1476
- coresdk::{workflow_commands, IntoPayloadsExt},
1567
+ coresdk::{IntoPayloadsExt, workflow_commands},
1477
1568
  temporal::api::{
1478
1569
  common::v1::{ActivityType, WorkflowType},
1479
1570
  enums::v1::CommandType,
@@ -1538,6 +1629,13 @@ pub mod temporal {
1538
1629
  attributes: Some(a),
1539
1630
  user_metadata: Default::default(),
1540
1631
  },
1632
+ a @ Attributes::RequestCancelNexusOperationCommandAttributes(_) => {
1633
+ Self {
1634
+ command_type: CommandType::RequestCancelNexusOperation as i32,
1635
+ attributes: Some(a),
1636
+ user_metadata: Default::default(),
1637
+ }
1638
+ }
1541
1639
  _ => unimplemented!(),
1542
1640
  }
1543
1641
  }
@@ -1551,6 +1649,70 @@ pub mod temporal {
1551
1649
  }
1552
1650
  }
1553
1651
 
1652
+ pub trait CommandAttributesExt {
1653
+ fn as_type(&self) -> CommandType;
1654
+ }
1655
+
1656
+ impl CommandAttributesExt for command::Attributes {
1657
+ fn as_type(&self) -> CommandType {
1658
+ match self {
1659
+ Attributes::ScheduleActivityTaskCommandAttributes(_) => {
1660
+ CommandType::ScheduleActivityTask
1661
+ }
1662
+ Attributes::StartTimerCommandAttributes(_) => CommandType::StartTimer,
1663
+ Attributes::CompleteWorkflowExecutionCommandAttributes(_) => {
1664
+ CommandType::CompleteWorkflowExecution
1665
+ }
1666
+ Attributes::FailWorkflowExecutionCommandAttributes(_) => {
1667
+ CommandType::FailWorkflowExecution
1668
+ }
1669
+ Attributes::RequestCancelActivityTaskCommandAttributes(_) => {
1670
+ CommandType::RequestCancelActivityTask
1671
+ }
1672
+ Attributes::CancelTimerCommandAttributes(_) => CommandType::CancelTimer,
1673
+ Attributes::CancelWorkflowExecutionCommandAttributes(_) => {
1674
+ CommandType::CancelWorkflowExecution
1675
+ }
1676
+ Attributes::RequestCancelExternalWorkflowExecutionCommandAttributes(
1677
+ _,
1678
+ ) => CommandType::RequestCancelExternalWorkflowExecution,
1679
+ Attributes::RecordMarkerCommandAttributes(_) => {
1680
+ CommandType::RecordMarker
1681
+ }
1682
+ Attributes::ContinueAsNewWorkflowExecutionCommandAttributes(_) => {
1683
+ CommandType::ContinueAsNewWorkflowExecution
1684
+ }
1685
+ Attributes::StartChildWorkflowExecutionCommandAttributes(_) => {
1686
+ CommandType::StartChildWorkflowExecution
1687
+ }
1688
+ Attributes::SignalExternalWorkflowExecutionCommandAttributes(_) => {
1689
+ CommandType::SignalExternalWorkflowExecution
1690
+ }
1691
+ Attributes::UpsertWorkflowSearchAttributesCommandAttributes(_) => {
1692
+ CommandType::UpsertWorkflowSearchAttributes
1693
+ }
1694
+ Attributes::ProtocolMessageCommandAttributes(_) => {
1695
+ CommandType::ProtocolMessage
1696
+ }
1697
+ Attributes::ModifyWorkflowPropertiesCommandAttributes(_) => {
1698
+ CommandType::ModifyWorkflowProperties
1699
+ }
1700
+ Attributes::ScheduleNexusOperationCommandAttributes(_) => {
1701
+ CommandType::ScheduleNexusOperation
1702
+ }
1703
+ Attributes::RequestCancelNexusOperationCommandAttributes(_) => {
1704
+ CommandType::RequestCancelNexusOperation
1705
+ }
1706
+ }
1707
+ }
1708
+ }
1709
+
1710
+ impl Display for command::Attributes {
1711
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1712
+ write!(f, "{:?}", self.as_type())
1713
+ }
1714
+ }
1715
+
1554
1716
  impl From<workflow_commands::StartTimer> for command::Attributes {
1555
1717
  fn from(s: workflow_commands::StartTimer) -> Self {
1556
1718
  Self::StartTimerCommandAttributes(StartTimerCommandAttributes {
@@ -1608,6 +1770,7 @@ pub mod temporal {
1608
1770
  retry_policy: s.retry_policy.map(Into::into),
1609
1771
  request_eager_execution: !s.do_not_eagerly_execute,
1610
1772
  use_workflow_build_id,
1773
+ priority: s.priority,
1611
1774
  },
1612
1775
  )
1613
1776
  }
@@ -1637,6 +1800,7 @@ pub mod temporal {
1637
1800
  cron_schedule: s.cron_schedule.clone(),
1638
1801
  parent_close_policy: s.parent_close_policy,
1639
1802
  inherit_build_id,
1803
+ priority: s.priority,
1640
1804
  },
1641
1805
  )
1642
1806
  }
@@ -1701,9 +1865,29 @@ pub mod temporal {
1701
1865
  )
1702
1866
  }
1703
1867
  }
1868
+
1869
+ impl From<workflow_commands::ScheduleNexusOperation> for command::Attributes {
1870
+ fn from(c: workflow_commands::ScheduleNexusOperation) -> Self {
1871
+ Self::ScheduleNexusOperationCommandAttributes(
1872
+ ScheduleNexusOperationCommandAttributes {
1873
+ endpoint: c.endpoint,
1874
+ service: c.service,
1875
+ operation: c.operation,
1876
+ input: c.input,
1877
+ schedule_to_close_timeout: c.schedule_to_close_timeout,
1878
+ nexus_header: c.nexus_header,
1879
+ },
1880
+ )
1881
+ }
1882
+ }
1704
1883
  }
1705
1884
  }
1706
1885
  pub mod cloud {
1886
+ pub mod account {
1887
+ pub mod v1 {
1888
+ tonic::include_proto!("temporal.api.cloud.account.v1");
1889
+ }
1890
+ }
1707
1891
  pub mod cloudservice {
1708
1892
  pub mod v1 {
1709
1893
  tonic::include_proto!("temporal.api.cloud.cloudservice.v1");
@@ -1719,6 +1903,11 @@ pub mod temporal {
1719
1903
  tonic::include_proto!("temporal.api.cloud.namespace.v1");
1720
1904
  }
1721
1905
  }
1906
+ pub mod nexus {
1907
+ pub mod v1 {
1908
+ tonic::include_proto!("temporal.api.cloud.nexus.v1");
1909
+ }
1910
+ }
1722
1911
  pub mod operation {
1723
1912
  pub mod v1 {
1724
1913
  tonic::include_proto!("temporal.api.cloud.operation.v1");
@@ -1729,11 +1918,26 @@ pub mod temporal {
1729
1918
  tonic::include_proto!("temporal.api.cloud.region.v1");
1730
1919
  }
1731
1920
  }
1921
+ pub mod resource {
1922
+ pub mod v1 {
1923
+ tonic::include_proto!("temporal.api.cloud.resource.v1");
1924
+ }
1925
+ }
1926
+ pub mod sink {
1927
+ pub mod v1 {
1928
+ tonic::include_proto!("temporal.api.cloud.sink.v1");
1929
+ }
1930
+ }
1931
+ pub mod usage {
1932
+ pub mod v1 {
1933
+ tonic::include_proto!("temporal.api.cloud.usage.v1");
1934
+ }
1935
+ }
1732
1936
  }
1733
1937
  pub mod common {
1734
1938
  pub mod v1 {
1735
1939
  use crate::{ENCODING_PAYLOAD_KEY, JSON_ENCODING_VAL};
1736
- use base64::{prelude::BASE64_STANDARD, Engine};
1940
+ use base64::{Engine, prelude::BASE64_STANDARD};
1737
1941
  use std::{
1738
1942
  collections::HashMap,
1739
1943
  fmt::{Display, Formatter},
@@ -1863,6 +2067,11 @@ pub mod temporal {
1863
2067
  }
1864
2068
  }
1865
2069
  }
2070
+ pub mod deployment {
2071
+ pub mod v1 {
2072
+ tonic::include_proto!("temporal.api.deployment.v1");
2073
+ }
2074
+ }
1866
2075
  pub mod enums {
1867
2076
  pub mod v1 {
1868
2077
  tonic::include_proto!("temporal.api.enums.v1");
@@ -1927,6 +2136,8 @@ pub mod temporal {
1927
2136
  | EventType::TimerStarted
1928
2137
  | EventType::UpsertWorkflowSearchAttributes
1929
2138
  | EventType::WorkflowPropertiesModified
2139
+ | EventType::NexusOperationScheduled
2140
+ | EventType::NexusOperationCancelRequested
1930
2141
  | EventType::WorkflowExecutionCanceled
1931
2142
  | EventType::WorkflowExecutionCompleted
1932
2143
  | EventType::WorkflowExecutionContinuedAsNew
@@ -1971,6 +2182,12 @@ pub mod temporal {
1971
2182
  Attributes::WorkflowTaskCompletedEventAttributes(a) => Some(a.scheduled_event_id),
1972
2183
  Attributes::WorkflowTaskTimedOutEventAttributes(a) => Some(a.scheduled_event_id),
1973
2184
  Attributes::WorkflowTaskFailedEventAttributes(a) => Some(a.scheduled_event_id),
2185
+ Attributes::NexusOperationStartedEventAttributes(a) => Some(a.scheduled_event_id),
2186
+ Attributes::NexusOperationCompletedEventAttributes(a) => Some(a.scheduled_event_id),
2187
+ Attributes::NexusOperationFailedEventAttributes(a) => Some(a.scheduled_event_id),
2188
+ Attributes::NexusOperationTimedOutEventAttributes(a) => Some(a.scheduled_event_id),
2189
+ Attributes::NexusOperationCanceledEventAttributes(a) => Some(a.scheduled_event_id),
2190
+ Attributes::NexusOperationCancelRequestedEventAttributes(a) => Some(a.scheduled_event_id),
1974
2191
  _ => None
1975
2192
  }
1976
2193
  })
@@ -2078,6 +2295,7 @@ pub mod temporal {
2078
2295
  Attributes::NexusOperationCanceledEventAttributes(_) => { EventType::NexusOperationCanceled }
2079
2296
  Attributes::NexusOperationTimedOutEventAttributes(_) => { EventType::NexusOperationTimedOut }
2080
2297
  Attributes::NexusOperationCancelRequestedEventAttributes(_) => { EventType::NexusOperationCancelRequested }
2298
+ Attributes::WorkflowExecutionOptionsUpdatedEventAttributes(_) => { EventType::WorkflowExecutionOptionsUpdated }
2081
2299
  }
2082
2300
  }
2083
2301
  }
@@ -2174,7 +2392,123 @@ pub mod temporal {
2174
2392
  }
2175
2393
  pub mod nexus {
2176
2394
  pub mod v1 {
2395
+ use crate::temporal::api::{
2396
+ common,
2397
+ common::v1::link::{WorkflowEvent, workflow_event},
2398
+ enums::v1::EventType,
2399
+ };
2400
+ use anyhow::{anyhow, bail};
2401
+ use std::fmt::{Display, Formatter};
2402
+ use tonic::transport::Uri;
2403
+
2177
2404
  tonic::include_proto!("temporal.api.nexus.v1");
2405
+
2406
+ impl Display for Response {
2407
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2408
+ write!(f, "NexusResponse(",)?;
2409
+ match &self.variant {
2410
+ None => {}
2411
+ Some(v) => {
2412
+ write!(f, "{v}")?;
2413
+ }
2414
+ }
2415
+ write!(f, ")")
2416
+ }
2417
+ }
2418
+
2419
+ impl Display for response::Variant {
2420
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2421
+ match self {
2422
+ response::Variant::StartOperation(_) => {
2423
+ write!(f, "StartOperation")
2424
+ }
2425
+ response::Variant::CancelOperation(_) => {
2426
+ write!(f, "CancelOperation")
2427
+ }
2428
+ }
2429
+ }
2430
+ }
2431
+
2432
+ impl Display for HandlerError {
2433
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2434
+ write!(f, "HandlerError")
2435
+ }
2436
+ }
2437
+
2438
+ static SCHEME_PREFIX: &str = "temporal://";
2439
+
2440
+ /// Attempt to parse a nexus lint into a workflow event link
2441
+ pub fn workflow_event_link_from_nexus(
2442
+ l: &Link,
2443
+ ) -> Result<common::v1::Link, anyhow::Error> {
2444
+ if !l.url.starts_with(SCHEME_PREFIX) {
2445
+ bail!("Invalid scheme for nexus link: {:?}", l.url);
2446
+ }
2447
+ // We strip the scheme/authority portion because of
2448
+ // https://github.com/hyperium/http/issues/696
2449
+ let no_authority_url = l.url.strip_prefix(SCHEME_PREFIX).unwrap();
2450
+ let uri = Uri::try_from(no_authority_url)?;
2451
+ let parts = uri.into_parts();
2452
+ let path = parts.path_and_query.ok_or_else(|| {
2453
+ anyhow!("Failed to parse nexus link, invalid path: {:?}", l)
2454
+ })?;
2455
+ let path_parts = path.path().split('/').collect::<Vec<_>>();
2456
+ if path_parts.get(1) != Some(&"namespaces") {
2457
+ bail!("Invalid path for nexus link: {:?}", l);
2458
+ }
2459
+ let namespace = path_parts.get(2).ok_or_else(|| {
2460
+ anyhow!("Failed to parse nexus link, no namespace: {:?}", l)
2461
+ })?;
2462
+ if path_parts.get(3) != Some(&"workflows") {
2463
+ bail!("Invalid path for nexus link, no workflows segment: {:?}", l);
2464
+ }
2465
+ let workflow_id = path_parts.get(4).ok_or_else(|| {
2466
+ anyhow!("Failed to parse nexus link, no workflow id: {:?}", l)
2467
+ })?;
2468
+ let run_id = path_parts
2469
+ .get(5)
2470
+ .ok_or_else(|| anyhow!("Failed to parse nexus link, no run id: {:?}", l))?;
2471
+ if path_parts.get(6) != Some(&"history") {
2472
+ bail!("Invalid path for nexus link, no history segment: {:?}", l);
2473
+ }
2474
+ let reference = if let Some(query) = path.query() {
2475
+ let mut eventref = workflow_event::EventReference::default();
2476
+ let query_parts = query.split('&').collect::<Vec<_>>();
2477
+ for qp in query_parts {
2478
+ let mut kv = qp.split('=');
2479
+ let key = kv.next().ok_or_else(|| {
2480
+ anyhow!("Failed to parse nexus link query parameter: {:?}", l)
2481
+ })?;
2482
+ let val = kv.next().ok_or_else(|| {
2483
+ anyhow!("Failed to parse nexus link query parameter: {:?}", l)
2484
+ })?;
2485
+ match key {
2486
+ "eventID" => {
2487
+ eventref.event_id = val.parse().map_err(|_| {
2488
+ anyhow!("Failed to parse nexus link event id: {:?}", l)
2489
+ })?;
2490
+ }
2491
+ "eventType" => {
2492
+ eventref.event_type =
2493
+ EventType::from_str_name(val).unwrap_or_default().into()
2494
+ }
2495
+ _ => continue,
2496
+ }
2497
+ }
2498
+ Some(workflow_event::Reference::EventRef(eventref))
2499
+ } else {
2500
+ None
2501
+ };
2502
+
2503
+ Ok(common::v1::Link {
2504
+ variant: Some(common::v1::link::Variant::WorkflowEvent(WorkflowEvent {
2505
+ namespace: namespace.to_string(),
2506
+ workflow_id: workflow_id.to_string(),
2507
+ run_id: run_id.to_string(),
2508
+ reference,
2509
+ })),
2510
+ })
2511
+ }
2178
2512
  }
2179
2513
  }
2180
2514
  pub mod workflowservice {
@@ -2195,10 +2529,8 @@ pub mod temporal {
2195
2529
  if let Some((sch, st)) =
2196
2530
  self.$sched_field.clone().zip(self.started_time.clone())
2197
2531
  {
2198
- let sch: Result<SystemTime, _> = sch.try_into();
2199
- let st: Result<SystemTime, _> = st.try_into();
2200
- if let (Ok(sch), Ok(st)) = (sch, st) {
2201
- return st.duration_since(sch).ok();
2532
+ if let Some(value) = elapsed_between_prost_times(sch, st) {
2533
+ return value;
2202
2534
  }
2203
2535
  }
2204
2536
  None
@@ -2206,6 +2538,18 @@ pub mod temporal {
2206
2538
  };
2207
2539
  }
2208
2540
 
2541
+ fn elapsed_between_prost_times(
2542
+ from: prost_wkt_types::Timestamp,
2543
+ to: prost_wkt_types::Timestamp,
2544
+ ) -> Option<Option<Duration>> {
2545
+ let from: Result<SystemTime, _> = from.try_into();
2546
+ let to: Result<SystemTime, _> = to.try_into();
2547
+ if let (Ok(from), Ok(to)) = (from, to) {
2548
+ return Some(to.duration_since(from).ok());
2549
+ }
2550
+ None
2551
+ }
2552
+
2209
2553
  impl PollWorkflowTaskQueueResponse {
2210
2554
  sched_to_start_impl!(scheduled_time);
2211
2555
  }
@@ -2252,6 +2596,23 @@ pub mod temporal {
2252
2596
  sched_to_start_impl!(current_attempt_scheduled_time);
2253
2597
  }
2254
2598
 
2599
+ impl PollNexusTaskQueueResponse {
2600
+ pub fn sched_to_start(&self) -> Option<Duration> {
2601
+ if let Some((sch, st)) = self
2602
+ .request
2603
+ .as_ref()
2604
+ .and_then(|r| r.scheduled_time)
2605
+ .clone()
2606
+ .zip(SystemTime::now().try_into().ok())
2607
+ {
2608
+ if let Some(value) = elapsed_between_prost_times(sch, st) {
2609
+ return value;
2610
+ }
2611
+ }
2612
+ None
2613
+ }
2614
+ }
2615
+
2255
2616
  impl QueryWorkflowResponse {
2256
2617
  /// Unwrap a successful response as vec of payloads
2257
2618
  pub fn unwrap(self) -> Vec<crate::temporal::api::common::v1::Payload> {
@@ -2277,6 +2638,25 @@ pub mod grpc {
2277
2638
  }
2278
2639
  }
2279
2640
 
2641
+ /// Case conversion, used for json -> proto enum string conversion
2642
+ pub fn camel_case_to_screaming_snake(val: &str) -> String {
2643
+ let mut out = String::new();
2644
+ let mut last_was_upper = true;
2645
+ for c in val.chars() {
2646
+ if c.is_uppercase() {
2647
+ if !last_was_upper {
2648
+ out.push('_');
2649
+ }
2650
+ out.push(c.to_ascii_uppercase());
2651
+ last_was_upper = true;
2652
+ } else {
2653
+ out.push(c.to_ascii_uppercase());
2654
+ last_was_upper = false;
2655
+ }
2656
+ }
2657
+ out
2658
+ }
2659
+
2280
2660
  #[cfg(test)]
2281
2661
  mod tests {
2282
2662
  use crate::temporal::api::failure::v1::Failure;