@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
@@ -1,12 +1,12 @@
1
1
  use crate::{
2
- panic_formatter, CancellableID, RustWfCmd, SignalData, TimerResult, UnblockEvent,
3
- UpdateContext, UpdateFunctions, UpdateInfo, WfContext, WfExitValue, WorkflowFunction,
4
- WorkflowResult,
2
+ CancellableID, RustWfCmd, SignalData, TimerResult, UnblockEvent, UpdateContext,
3
+ UpdateFunctions, UpdateInfo, WfContext, WfExitValue, WorkflowFunction, WorkflowResult,
4
+ panic_formatter,
5
5
  };
6
- use anyhow::{anyhow, bail, Context as AnyhowContext, Error};
7
- use futures_util::{future::BoxFuture, FutureExt};
6
+ use anyhow::{Context as AnyhowContext, Error, anyhow, bail};
7
+ use futures_util::{FutureExt, future::BoxFuture};
8
8
  use std::{
9
- collections::{hash_map::Entry, HashMap},
9
+ collections::{HashMap, hash_map::Entry},
10
10
  future::Future,
11
11
  panic,
12
12
  panic::AssertUnwindSafe,
@@ -17,25 +17,26 @@ use std::{
17
17
  use temporal_sdk_core_protos::{
18
18
  coresdk::{
19
19
  workflow_activation::{
20
- workflow_activation_job::Variant, FireTimer, NotifyHasPatch, ResolveActivity,
20
+ FireTimer, InitializeWorkflow, NotifyHasPatch, ResolveActivity,
21
21
  ResolveChildWorkflowExecution, ResolveChildWorkflowExecutionStart, WorkflowActivation,
22
- WorkflowActivationJob,
22
+ WorkflowActivationJob, workflow_activation_job::Variant,
23
23
  },
24
24
  workflow_commands::{
25
- request_cancel_external_workflow_execution as cancel_we, update_response,
26
- workflow_command, CancelChildWorkflowExecution, CancelSignalWorkflow, CancelTimer,
25
+ CancelChildWorkflowExecution, CancelSignalWorkflow, CancelTimer,
27
26
  CancelWorkflowExecution, CompleteWorkflowExecution, FailWorkflowExecution,
28
27
  RequestCancelActivity, RequestCancelExternalWorkflowExecution,
29
- RequestCancelLocalActivity, ScheduleActivity, ScheduleLocalActivity,
30
- StartChildWorkflowExecution, StartTimer, UpdateResponse,
28
+ RequestCancelLocalActivity, RequestCancelNexusOperation, ScheduleActivity,
29
+ ScheduleLocalActivity, StartTimer, UpdateResponse, WorkflowCommand, update_response,
30
+ workflow_command,
31
31
  },
32
- workflow_completion::WorkflowActivationCompletion,
32
+ workflow_completion,
33
+ workflow_completion::{WorkflowActivationCompletion, workflow_activation_completion},
33
34
  },
34
35
  temporal::api::{common::v1::Payload, failure::v1::Failure},
35
36
  utilities::TryIntoOrNone,
36
37
  };
37
38
  use tokio::sync::{
38
- mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
39
+ mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel},
39
40
  oneshot, watch,
40
41
  };
41
42
  use tracing::Instrument;
@@ -43,26 +44,25 @@ use tracing::Instrument;
43
44
  impl WorkflowFunction {
44
45
  /// Start a workflow function, returning a future that will resolve when the workflow does,
45
46
  /// and a channel that can be used to send it activations.
46
- #[doc(hidden)]
47
- pub fn start_workflow(
47
+ pub(crate) fn start_workflow(
48
48
  &self,
49
49
  namespace: String,
50
50
  task_queue: String,
51
- workflow_type: &str,
52
- args: Vec<Payload>,
51
+ init_workflow_job: InitializeWorkflow,
53
52
  outgoing_completions: UnboundedSender<WorkflowActivationCompletion>,
54
53
  ) -> (
55
- impl Future<Output = WorkflowResult<Payload>>,
54
+ impl Future<Output = WorkflowResult<Payload>> + use<>,
56
55
  UnboundedSender<WorkflowActivation>,
57
56
  ) {
58
- let (cancel_tx, cancel_rx) = watch::channel(false);
59
- let (wf_context, cmd_receiver) = WfContext::new(namespace, task_queue, args, cancel_rx);
60
- let (tx, incoming_activations) = unbounded_channel();
57
+ let (cancel_tx, cancel_rx) = watch::channel(None);
61
58
  let span = info_span!(
62
59
  "RunWorkflow",
63
- "otel.name" = format!("RunWorkflow:{}", workflow_type),
60
+ "otel.name" = format!("RunWorkflow:{}", &init_workflow_job.workflow_type),
64
61
  "otel.kind" = "server"
65
62
  );
63
+ let (wf_context, cmd_receiver) =
64
+ WfContext::new(namespace, task_queue, init_workflow_job, cancel_rx);
65
+ let (tx, incoming_activations) = unbounded_channel();
66
66
  let inner_fut = (self.wf_func)(wf_context.clone()).instrument(span);
67
67
  (
68
68
  WorkflowFuture {
@@ -76,7 +76,6 @@ impl WorkflowFunction {
76
76
  incoming_activations,
77
77
  command_status: Default::default(),
78
78
  cancel_sender: cancel_tx,
79
- child_workflow_starts: Default::default(),
80
79
  sig_chans: Default::default(),
81
80
  updates: Default::default(),
82
81
  update_futures: Default::default(),
@@ -111,11 +110,9 @@ pub(crate) struct WorkflowFuture {
111
110
  /// Commands by ID -> blocked status
112
111
  command_status: HashMap<CommandID, WFCommandFutInfo>,
113
112
  /// Use to notify workflow code of cancellation
114
- cancel_sender: watch::Sender<bool>,
113
+ cancel_sender: watch::Sender<Option<String>>,
115
114
  /// Copy of the workflow context
116
115
  wf_ctx: WfContext,
117
- /// Mapping of sequence number to a StartChildWorkflowExecution request
118
- child_workflow_starts: HashMap<u32, StartChildWorkflowExecution>,
119
116
  /// Maps signal IDs to channels to send down when they are signaled
120
117
  sig_chans: HashMap<String, SigChanOrBuffer>,
121
118
  /// Maps update handlers by name to implementations
@@ -133,6 +130,8 @@ impl WorkflowFuture {
133
130
  UnblockEvent::WorkflowComplete(seq, _) => CommandID::ChildWorkflowComplete(seq),
134
131
  UnblockEvent::SignalExternal(seq, _) => CommandID::SignalExternal(seq),
135
132
  UnblockEvent::CancelExternal(seq, _) => CommandID::CancelExternal(seq),
133
+ UnblockEvent::NexusOperationStart(seq, _) => CommandID::NexusOpStart(seq),
134
+ UnblockEvent::NexusOperationComplete(seq, _) => CommandID::NexusOpComplete(seq),
136
135
  };
137
136
  let unblocker = self.command_status.remove(&cmd_id);
138
137
  let _ = unblocker
@@ -153,12 +152,17 @@ impl WorkflowFuture {
153
152
  .expect("Completion channel intact");
154
153
  }
155
154
 
156
- fn send_completion(&self, run_id: String, activation_cmds: Vec<workflow_command::Variant>) {
155
+ fn send_completion(&self, run_id: String, activation_cmds: Vec<WorkflowCommand>) {
157
156
  self.outgoing_completions
158
- .send(WorkflowActivationCompletion::from_cmds(
157
+ .send(WorkflowActivationCompletion {
159
158
  run_id,
160
- activation_cmds,
161
- ))
159
+ status: Some(workflow_activation_completion::Status::Successful(
160
+ workflow_completion::Success {
161
+ commands: activation_cmds,
162
+ used_internal_flags: vec![],
163
+ },
164
+ )),
165
+ })
162
166
  .expect("Completion channel intact");
163
167
  }
164
168
 
@@ -171,7 +175,7 @@ impl WorkflowFuture {
171
175
  fn handle_job(
172
176
  &mut self,
173
177
  variant: Option<Variant>,
174
- outgoing_cmds: &mut Vec<workflow_command::Variant>,
178
+ outgoing_cmds: &mut Vec<WorkflowCommand>,
175
179
  ) -> Result<bool, Error> {
176
180
  if let Some(v) = variant {
177
181
  match v {
@@ -207,13 +211,13 @@ impl WorkflowFuture {
207
211
  Variant::QueryWorkflow(q) => {
208
212
  error!(
209
213
  "Queries are not implemented in the Rust SDK. Got query '{}'",
210
- q.query_id
214
+ q.query_type
211
215
  );
212
216
  }
213
- Variant::CancelWorkflow(_) => {
217
+ Variant::CancelWorkflow(c) => {
214
218
  // TODO: Cancel pending futures, etc
215
219
  self.cancel_sender
216
- .send(true)
220
+ .send(Some(c.reason))
217
221
  .expect("Cancel rx not dropped");
218
222
  }
219
223
  Variant::SignalWorkflow(sig) => {
@@ -224,7 +228,7 @@ impl WorkflowFuture {
224
228
  SigChanOrBuffer::Chan(chan) => {
225
229
  let _ = chan.send(dat);
226
230
  }
227
- SigChanOrBuffer::Buffer(ref mut buf) => buf.push(dat),
231
+ SigChanOrBuffer::Buffer(buf) => buf.push(dat),
228
232
  },
229
233
  Entry::Vacant(v) => {
230
234
  v.insert(SigChanOrBuffer::Buffer(vec![dat]));
@@ -261,10 +265,13 @@ impl WorkflowFuture {
261
265
  };
262
266
  match val_res {
263
267
  Ok(_) => {
264
- outgoing_cmds.push(update_response(
265
- u.protocol_instance_id.clone(),
266
- update_response::Response::Accepted(()),
267
- ));
268
+ outgoing_cmds.push(
269
+ update_response(
270
+ u.protocol_instance_id.clone(),
271
+ update_response::Response::Accepted(()),
272
+ )
273
+ .into(),
274
+ );
268
275
  let handler_fut = (impls.handler)(
269
276
  UpdateContext {
270
277
  wf_ctx: self.wf_ctx.clone(),
@@ -276,23 +283,47 @@ impl WorkflowFuture {
276
283
  .push((u.protocol_instance_id, handler_fut));
277
284
  }
278
285
  Err(e) => {
279
- outgoing_cmds.push(update_response(
280
- u.protocol_instance_id,
281
- update_response::Response::Rejected(e.into()),
282
- ));
286
+ outgoing_cmds.push(
287
+ update_response(
288
+ u.protocol_instance_id,
289
+ update_response::Response::Rejected(e.into()),
290
+ )
291
+ .into(),
292
+ );
283
293
  }
284
294
  }
285
295
  } else {
286
- outgoing_cmds.push(update_response(
287
- u.protocol_instance_id,
288
- update_response::Response::Rejected(
289
- format!("No update handler registered for update name {}", u.name)
296
+ outgoing_cmds.push(
297
+ update_response(
298
+ u.protocol_instance_id,
299
+ update_response::Response::Rejected(
300
+ format!(
301
+ "No update handler registered for update name {}",
302
+ u.name
303
+ )
290
304
  .into(),
291
- ),
292
- ));
305
+ ),
306
+ )
307
+ .into(),
308
+ );
293
309
  }
294
310
  }
295
-
311
+ Variant::ResolveNexusOperationStart(attrs) => {
312
+ self.unblock(UnblockEvent::NexusOperationStart(
313
+ attrs.seq,
314
+ Box::new(
315
+ attrs
316
+ .status
317
+ .context("Nexus operation start must have status")?,
318
+ ),
319
+ ))?
320
+ }
321
+ Variant::ResolveNexusOperation(attrs) => {
322
+ self.unblock(UnblockEvent::NexusOperationComplete(
323
+ attrs.seq,
324
+ Box::new(attrs.result.context("Nexus operation must have result")?),
325
+ ))?
326
+ }
296
327
  Variant::RemoveFromCache(_) => {
297
328
  // TODO: Need to abort any user-spawned tasks, etc. See also cancel WF.
298
329
  // How best to do this in executor agnostic way? Is that possible?
@@ -314,13 +345,13 @@ impl Future for WorkflowFuture {
314
345
  fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
315
346
  'activations: loop {
316
347
  // WF must always receive an activation first before responding with commands
317
- let mut activation = match self.incoming_activations.poll_recv(cx) {
348
+ let activation = match self.incoming_activations.poll_recv(cx) {
318
349
  Poll::Ready(a) => match a {
319
350
  Some(act) => act,
320
351
  None => {
321
352
  return Poll::Ready(Err(anyhow!(
322
353
  "Workflow future's activation channel was lost!"
323
- )))
354
+ )));
324
355
  }
325
356
  },
326
357
  Poll::Pending => return Poll::Pending,
@@ -342,18 +373,6 @@ impl Future for WorkflowFuture {
342
373
 
343
374
  let mut die_of_eviction_when_done = false;
344
375
  let mut activation_cmds = vec![];
345
- // Assign initial state from start workflow job
346
- if let Some(start_info) = activation.jobs.iter_mut().find_map(|j| {
347
- if let Some(Variant::InitializeWorkflow(s)) = j.variant.as_mut() {
348
- Some(s)
349
- } else {
350
- None
351
- }
352
- }) {
353
- let mut wlock = self.wf_ctx.shared.write();
354
- wlock.random_seed = start_info.randomness_seed;
355
- wlock.search_attributes = start_info.search_attributes.take().unwrap_or_default();
356
- };
357
376
  // Lame hack to avoid hitting "unregistered" update handlers in a situation where
358
377
  // the history has no commands until an update is accepted. Will go away w/ SDK redesign
359
378
  if activation
@@ -450,7 +469,7 @@ impl WorkflowFuture {
450
469
  &mut self,
451
470
  cx: &mut Context,
452
471
  run_id: &str,
453
- activation_cmds: &mut Vec<workflow_command::Variant>,
472
+ activation_cmds: &mut Vec<WorkflowCommand>,
454
473
  ) -> Result<bool, Error> {
455
474
  // TODO: Make sure this is *actually* safe before un-prototyping rust sdk
456
475
  let mut res = match AssertUnwindSafe(&mut self.inner)
@@ -480,68 +499,61 @@ impl WorkflowFuture {
480
499
  while let Ok(cmd) = self.incoming_commands.try_recv() {
481
500
  match cmd {
482
501
  RustWfCmd::Cancel(cancellable_id) => {
483
- match cancellable_id {
502
+ let cmd_variant = match cancellable_id {
484
503
  CancellableID::Timer(seq) => {
485
- activation_cmds
486
- .push(workflow_command::Variant::CancelTimer(CancelTimer { seq }));
487
504
  self.unblock(UnblockEvent::Timer(seq, TimerResult::Cancelled))?;
488
505
  // Re-poll wf future since a timer is now unblocked
489
506
  res = self.inner.poll_unpin(cx);
507
+ workflow_command::Variant::CancelTimer(CancelTimer { seq })
490
508
  }
491
509
  CancellableID::Activity(seq) => {
492
- activation_cmds.push(workflow_command::Variant::RequestCancelActivity(
510
+ workflow_command::Variant::RequestCancelActivity(
493
511
  RequestCancelActivity { seq },
494
- ));
512
+ )
495
513
  }
496
514
  CancellableID::LocalActivity(seq) => {
497
- activation_cmds.push(
498
- workflow_command::Variant::RequestCancelLocalActivity(
499
- RequestCancelLocalActivity { seq },
500
- ),
501
- );
515
+ workflow_command::Variant::RequestCancelLocalActivity(
516
+ RequestCancelLocalActivity { seq },
517
+ )
502
518
  }
503
- CancellableID::ChildWorkflow(seq) => {
504
- activation_cmds.push(
505
- workflow_command::Variant::CancelChildWorkflowExecution(
506
- CancelChildWorkflowExecution {
507
- child_workflow_seq: seq,
508
- },
509
- ),
510
- );
519
+ CancellableID::ChildWorkflow { seqnum, reason } => {
520
+ workflow_command::Variant::CancelChildWorkflowExecution(
521
+ CancelChildWorkflowExecution {
522
+ child_workflow_seq: seqnum,
523
+ reason,
524
+ },
525
+ )
511
526
  }
512
527
  CancellableID::SignalExternalWorkflow(seq) => {
513
- activation_cmds.push(workflow_command::Variant::CancelSignalWorkflow(
514
- CancelSignalWorkflow { seq },
515
- ));
528
+ workflow_command::Variant::CancelSignalWorkflow(CancelSignalWorkflow {
529
+ seq,
530
+ })
516
531
  }
517
532
  CancellableID::ExternalWorkflow {
518
533
  seqnum,
519
534
  execution,
520
- only_child,
521
- } => {
522
- activation_cmds.push(
523
- workflow_command::Variant::RequestCancelExternalWorkflowExecution(
524
- RequestCancelExternalWorkflowExecution {
525
- seq: seqnum,
526
- target: Some(if only_child {
527
- cancel_we::Target::ChildWorkflowId(
528
- execution.workflow_id,
529
- )
530
- } else {
531
- cancel_we::Target::WorkflowExecution(execution)
532
- }),
533
- },
534
- ),
535
- );
535
+ reason,
536
+ } => workflow_command::Variant::RequestCancelExternalWorkflowExecution(
537
+ RequestCancelExternalWorkflowExecution {
538
+ seq: seqnum,
539
+ workflow_execution: Some(execution),
540
+ reason,
541
+ },
542
+ ),
543
+ CancellableID::NexusOp(seq) => {
544
+ workflow_command::Variant::RequestCancelNexusOperation(
545
+ RequestCancelNexusOperation { seq },
546
+ )
536
547
  }
537
- }
548
+ };
549
+ activation_cmds.push(cmd_variant.into());
538
550
  }
539
- RustWfCmd::NewCmd(cmd) => {
540
- activation_cmds.push(cmd.cmd.clone());
541
551
 
542
- let command_id = match cmd.cmd {
552
+ RustWfCmd::NewCmd(cmd) => {
553
+ let command_id = match cmd.cmd.variant.as_ref().expect("command variant is set")
554
+ {
543
555
  workflow_command::Variant::StartTimer(StartTimer { seq, .. }) => {
544
- CommandID::Timer(seq)
556
+ CommandID::Timer(*seq)
545
557
  }
546
558
  workflow_command::Variant::ScheduleActivity(ScheduleActivity {
547
559
  seq,
@@ -549,14 +561,12 @@ impl WorkflowFuture {
549
561
  })
550
562
  | workflow_command::Variant::ScheduleLocalActivity(
551
563
  ScheduleLocalActivity { seq, .. },
552
- ) => CommandID::Activity(seq),
564
+ ) => CommandID::Activity(*seq),
553
565
  workflow_command::Variant::SetPatchMarker(_) => {
554
566
  panic!("Set patch marker should be a nonblocking command")
555
567
  }
556
568
  workflow_command::Variant::StartChildWorkflowExecution(req) => {
557
569
  let seq = req.seq;
558
- // Save the start request to support cancellation later
559
- self.child_workflow_starts.insert(seq, req);
560
570
  CommandID::ChildWorkflowStart(seq)
561
571
  }
562
572
  workflow_command::Variant::SignalExternalWorkflowExecution(req) => {
@@ -565,8 +575,13 @@ impl WorkflowFuture {
565
575
  workflow_command::Variant::RequestCancelExternalWorkflowExecution(req) => {
566
576
  CommandID::CancelExternal(req.seq)
567
577
  }
578
+ workflow_command::Variant::ScheduleNexusOperation(req) => {
579
+ CommandID::NexusOpStart(req.seq)
580
+ }
568
581
  _ => unimplemented!("Command type not implemented"),
569
582
  };
583
+ activation_cmds.push(cmd.cmd);
584
+
570
585
  self.command_status.insert(
571
586
  command_id,
572
587
  WFCommandFutInfo {
@@ -575,7 +590,7 @@ impl WorkflowFuture {
575
590
  );
576
591
  }
577
592
  RustWfCmd::NewNonblockingCmd(cmd) => {
578
- activation_cmds.push(cmd);
593
+ activation_cmds.push(cmd.into());
579
594
  }
580
595
  RustWfCmd::SubscribeChildWorkflowCompletion(sub) => {
581
596
  self.command_status.insert(
@@ -604,42 +619,45 @@ impl WorkflowFuture {
604
619
  RustWfCmd::RegisterUpdate(name, impls) => {
605
620
  self.updates.insert(name, impls);
606
621
  }
622
+ RustWfCmd::SubscribeNexusOperationCompletion { seq, unblocker } => {
623
+ self.command_status.insert(
624
+ CommandID::NexusOpComplete(seq),
625
+ WFCommandFutInfo { unblocker },
626
+ );
627
+ }
607
628
  }
608
629
  }
609
630
 
610
631
  if let Poll::Ready(res) = res {
611
632
  // TODO: Auto reply with cancel when cancelled (instead of normal exit value)
612
- match res {
633
+ let cmd = match res {
613
634
  Ok(exit_val) => match exit_val {
614
635
  // TODO: Generic values
615
636
  WfExitValue::Normal(result) => {
616
- activation_cmds.push(workflow_command::Variant::CompleteWorkflowExecution(
637
+ workflow_command::Variant::CompleteWorkflowExecution(
617
638
  CompleteWorkflowExecution {
618
639
  result: Some(result),
619
640
  },
620
- ));
641
+ )
621
642
  }
622
- WfExitValue::ContinueAsNew(cmd) => activation_cmds.push((*cmd).into()),
623
- WfExitValue::Cancelled => {
624
- activation_cmds.push(workflow_command::Variant::CancelWorkflowExecution(
625
- CancelWorkflowExecution {},
626
- ));
643
+ WfExitValue::ContinueAsNew(cmd) => {
644
+ workflow_command::Variant::ContinueAsNewWorkflowExecution(*cmd)
627
645
  }
646
+ WfExitValue::Cancelled => workflow_command::Variant::CancelWorkflowExecution(
647
+ CancelWorkflowExecution {},
648
+ ),
628
649
  WfExitValue::Evicted => {
629
650
  panic!("Don't explicitly return this")
630
651
  }
631
652
  },
632
- Err(e) => {
633
- activation_cmds.push(workflow_command::Variant::FailWorkflowExecution(
634
- FailWorkflowExecution {
635
- failure: Some(Failure {
636
- message: e.to_string(),
637
- ..Default::default()
638
- }),
639
- },
640
- ));
641
- }
642
- }
653
+ Err(e) => workflow_command::Variant::FailWorkflowExecution(FailWorkflowExecution {
654
+ failure: Some(Failure {
655
+ message: e.to_string(),
656
+ ..Default::default()
657
+ }),
658
+ }),
659
+ };
660
+ activation_cmds.push(cmd.into())
643
661
  }
644
662
  Ok(false)
645
663
  }
@@ -653,6 +671,8 @@ enum CommandID {
653
671
  ChildWorkflowComplete(u32),
654
672
  SignalExternal(u32),
655
673
  CancelExternal(u32),
674
+ NexusOpStart(u32),
675
+ NexusOpComplete(u32),
656
676
  }
657
677
 
658
678
  fn update_response(
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  name = "temporal-sdk-core-protos"
3
3
  version = "0.1.0"
4
- edition = "2021"
4
+ edition = "2024"
5
5
  authors = ["Spencer Judge <spencer@temporal.io>"]
6
6
  license-file = { workspace = true }
7
7
  description = "Protobuf definitions for Temporal SDKs Core/Lang interface"
@@ -19,13 +19,12 @@ anyhow = "1.0"
19
19
  base64 = "0.22"
20
20
  derive_more = { workspace = true }
21
21
  prost = { workspace = true }
22
- prost-types = { workspace = true }
23
22
  prost-wkt = "0.6"
24
23
  prost-wkt-types = "0.6"
25
- rand = { version = "0.8", optional = true }
24
+ rand = { version = "0.9", optional = true }
26
25
  serde = { version = "1.0", features = ["derive"] }
27
26
  serde_json = "1.0"
28
- thiserror = "1.0"
27
+ thiserror = { workspace = true }
29
28
  tonic = { workspace = true }
30
29
  uuid = { version = "1.1", features = ["v4"], optional = true }
31
30
 
@@ -1 +1 @@
1
- 2024-05-13-00
1
+ 2024-10-01-00
@@ -0,0 +1,46 @@
1
+ syntax = "proto3";
2
+
3
+ package temporal.api.cloud.account.v1;
4
+
5
+ option go_package = "go.temporal.io/api/cloud/account/v1;account";
6
+ option java_package = "io.temporal.api.cloud.account.v1";
7
+ option java_multiple_files = true;
8
+ option java_outer_classname = "MessageProto";
9
+ option ruby_package = "Temporalio::Api::Cloud::Account::V1";
10
+ option csharp_namespace = "Temporalio.Api.Cloud.Account.V1";
11
+
12
+ import "temporal/api/cloud/resource/v1/message.proto";
13
+
14
+ message MetricsSpec {
15
+ // The ca cert(s) in PEM format that clients connecting to the metrics endpoint can use for authentication.
16
+ // This must only be one value, but the CA can have a chain.
17
+ bytes accepted_client_ca = 2;
18
+ }
19
+
20
+ message AccountSpec {
21
+ // The metrics specification for this account.
22
+ // If not specified, metrics will not be enabled.
23
+ MetricsSpec metrics = 1;
24
+ }
25
+
26
+ message Metrics {
27
+ // The prometheus metrics endpoint uri.
28
+ // This is only populated when the metrics is enabled in the metrics specification.
29
+ string uri = 1;
30
+ }
31
+
32
+ message Account {
33
+ // The id of the account.
34
+ string id = 1;
35
+ // The account specification.
36
+ AccountSpec spec = 2;
37
+ // The current version of the account specification.
38
+ // The next update operation will have to include this version.
39
+ string resource_version = 3;
40
+ // The current state of the account.
41
+ temporal.api.cloud.resource.v1.ResourceState state = 4;
42
+ // The id of the async operation that is updating the account, if any.
43
+ string async_operation_id = 5;
44
+ // Information related to metrics.
45
+ Metrics metrics = 6;
46
+ }