@temporalio/core-bridge 1.11.7 → 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.
- package/Cargo.lock +504 -341
- package/package.json +3 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +5 -0
- package/sdk-core/.github/workflows/per-pr.yml +59 -5
- package/sdk-core/Cargo.toml +3 -2
- package/sdk-core/client/Cargo.toml +3 -3
- package/sdk-core/client/src/lib.rs +154 -161
- package/sdk-core/client/src/metrics.rs +15 -8
- package/sdk-core/client/src/proxy.rs +1 -1
- package/sdk-core/client/src/raw.rs +176 -33
- package/sdk-core/client/src/retry.rs +102 -465
- package/sdk-core/client/src/worker_registry/mod.rs +2 -2
- package/sdk-core/client/src/workflow_handle/mod.rs +19 -1
- package/sdk-core/core/Cargo.toml +12 -14
- package/sdk-core/core/benches/workflow_replay.rs +1 -1
- package/sdk-core/core/src/abstractions.rs +2 -2
- package/sdk-core/core/src/core_tests/activity_tasks.rs +99 -46
- package/sdk-core/core/src/core_tests/child_workflows.rs +68 -9
- package/sdk-core/core/src/core_tests/determinism.rs +2 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +20 -33
- package/sdk-core/core/src/core_tests/mod.rs +7 -8
- package/sdk-core/core/src/core_tests/queries.rs +79 -79
- package/sdk-core/core/src/core_tests/replay_flag.rs +5 -5
- package/sdk-core/core/src/core_tests/updates.rs +6 -6
- package/sdk-core/core/src/core_tests/workers.rs +19 -22
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +3 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +154 -106
- package/sdk-core/core/src/ephemeral_server/mod.rs +66 -10
- package/sdk-core/core/src/internal_flags.rs +103 -12
- package/sdk-core/core/src/lib.rs +21 -13
- package/sdk-core/core/src/pollers/mod.rs +200 -6
- package/sdk-core/core/src/pollers/poll_buffer.rs +32 -8
- package/sdk-core/core/src/protosext/mod.rs +7 -7
- package/sdk-core/core/src/protosext/protocol_messages.rs +2 -2
- package/sdk-core/core/src/replay/mod.rs +8 -9
- package/sdk-core/core/src/retry_logic.rs +8 -6
- package/sdk-core/core/src/telemetry/log_export.rs +4 -4
- package/sdk-core/core/src/telemetry/metrics.rs +111 -25
- package/sdk-core/core/src/telemetry/mod.rs +11 -4
- package/sdk-core/core/src/telemetry/otel.rs +108 -144
- package/sdk-core/core/src/telemetry/prometheus_server.rs +1 -4
- package/sdk-core/core/src/test_help/mod.rs +27 -21
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -5
- package/sdk-core/core/src/worker/activities/local_activities.rs +9 -9
- package/sdk-core/core/src/worker/activities.rs +34 -46
- package/sdk-core/core/src/worker/client/mocks.rs +24 -2
- package/sdk-core/core/src/worker/client.rs +169 -33
- package/sdk-core/core/src/worker/mod.rs +132 -56
- package/sdk-core/core/src/worker/nexus.rs +410 -0
- package/sdk-core/core/src/worker/tuner/resource_based.rs +27 -5
- package/sdk-core/core/src/worker/tuner.rs +29 -2
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +8 -3
- package/sdk-core/core/src/worker/workflow/history_update.rs +5 -8
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +83 -87
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +38 -38
- package/sdk-core/core/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +117 -0
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +8 -18
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +114 -108
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +16 -31
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -14
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +8 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +34 -75
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +26 -48
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +10 -17
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +543 -0
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +22 -31
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +53 -51
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +40 -45
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +8 -10
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +24 -30
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +182 -116
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +4 -8
- package/sdk-core/core/src/worker/workflow/managed_run.rs +75 -45
- package/sdk-core/core/src/worker/workflow/mod.rs +104 -55
- package/sdk-core/core/src/worker/workflow/run_cache.rs +23 -4
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +4 -4
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +32 -13
- package/sdk-core/core-api/Cargo.toml +2 -3
- package/sdk-core/core-api/src/errors.rs +22 -20
- package/sdk-core/core-api/src/lib.rs +24 -5
- package/sdk-core/core-api/src/telemetry/metrics.rs +27 -1
- package/sdk-core/core-api/src/telemetry.rs +37 -3
- package/sdk-core/core-api/src/worker.rs +36 -3
- package/sdk-core/docker/docker-compose-ci.yaml +25 -0
- package/sdk-core/etc/otel-collector-ci.yaml +36 -0
- package/sdk-core/etc/otel-collector-config.yaml +3 -3
- package/sdk-core/etc/prometheus.yaml +1 -1
- package/sdk-core/fsm/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +3 -4
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
- package/sdk-core/sdk/Cargo.toml +1 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -1
- package/sdk-core/sdk/src/lib.rs +126 -54
- package/sdk-core/sdk/src/workflow_context/options.rs +184 -74
- package/sdk-core/sdk/src/workflow_context.rs +193 -79
- package/sdk-core/sdk/src/workflow_future.rs +151 -131
- package/sdk-core/sdk-core-protos/Cargo.toml +3 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +46 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +254 -5
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +108 -2
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +94 -15
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +102 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +84 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +25 -10
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +14 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +25 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +41 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +59 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +135 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/push-to-buf.yml +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +13 -21
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3386 -1047
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +3529 -1144
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +252 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +96 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/nexus.proto +42 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +43 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +13 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +14 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +70 -12
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +12 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/query/v1/message.proto +9 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +206 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +482 -97
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +230 -43
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/nexus/nexus.proto +71 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +55 -9
- package/sdk-core/sdk-core-protos/src/history_builder.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_info.rs +5 -6
- package/sdk-core/sdk-core-protos/src/lib.rs +414 -34
- package/sdk-core/sdk-core-protos/src/task_token.rs +1 -1
- package/sdk-core/test-utils/Cargo.toml +3 -11
- package/sdk-core/test-utils/src/canned_histories.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +159 -85
- package/sdk-core/tests/fuzzy_workflow.rs +3 -3
- package/sdk-core/tests/heavy_tests.rs +3 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +171 -20
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +45 -39
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +7 -6
- package/sdk-core/tests/integ_tests/metrics_tests.rs +492 -35
- package/sdk-core/tests/integ_tests/polling_tests.rs +7 -5
- package/sdk-core/tests/integ_tests/queries_tests.rs +14 -17
- package/sdk-core/tests/integ_tests/update_tests.rs +47 -44
- package/sdk-core/tests/integ_tests/visibility_tests.rs +4 -3
- package/sdk-core/tests/integ_tests/worker_tests.rs +5 -5
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +15 -13
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +28 -14
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +57 -4
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +24 -18
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +506 -0
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/priority.rs +104 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +34 -31
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +152 -116
- package/sdk-core/tests/main.rs +36 -6
- package/sdk-core/tests/runner.rs +30 -9
- package/src/conversions/slot_supplier_bridge.rs +4 -0
- package/src/conversions.rs +1 -0
- package/src/worker.rs +5 -7
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -78
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
use super::{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
EventInfo, NewMachineWithCommand, OnEventWrapper, WFMachinesAdapter, WFMachinesError,
|
|
3
|
+
workflow_machines::MachineResponse,
|
|
4
4
|
};
|
|
5
5
|
use crate::worker::workflow::machines::HistEventData;
|
|
6
|
-
use rustfsm::{
|
|
6
|
+
use rustfsm::{MachineError, StateMachine, TransitionResult, fsm};
|
|
7
7
|
use std::convert::TryFrom;
|
|
8
8
|
use temporal_sdk_core_protos::{
|
|
9
9
|
coresdk::{
|
|
10
|
+
IntoPayloadsExt,
|
|
10
11
|
common::NamespacedWorkflowExecution,
|
|
11
12
|
workflow_activation::ResolveSignalExternalWorkflow,
|
|
12
13
|
workflow_commands::{
|
|
13
|
-
signal_external_workflow_execution as sig_we,
|
|
14
|
+
SignalExternalWorkflowExecution, signal_external_workflow_execution as sig_we,
|
|
14
15
|
},
|
|
15
|
-
IntoPayloadsExt,
|
|
16
16
|
},
|
|
17
17
|
temporal::api::{
|
|
18
|
-
command::v1::{
|
|
18
|
+
command::v1::{SignalExternalWorkflowExecutionCommandAttributes, command},
|
|
19
19
|
common::v1::WorkflowExecution as UpstreamWE,
|
|
20
20
|
enums::v1::{CommandType, EventType, SignalExternalWorkflowExecutionFailedCause},
|
|
21
|
-
failure::v1::{
|
|
21
|
+
failure::v1::{ApplicationFailureInfo, CanceledFailureInfo, Failure, failure::FailureInfo},
|
|
22
22
|
history::v1::history_event,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
@@ -73,7 +73,7 @@ pub(super) fn new_external_signal(
|
|
|
73
73
|
None => {
|
|
74
74
|
return Err(WFMachinesError::Fatal(
|
|
75
75
|
"Signal external workflow command had empty target field".to_string(),
|
|
76
|
-
))
|
|
76
|
+
));
|
|
77
77
|
}
|
|
78
78
|
Some(sig_we::Target::ChildWorkflowId(wfid)) => (
|
|
79
79
|
NamespacedWorkflowExecution {
|
|
@@ -109,13 +109,8 @@ pub(super) fn new_external_signal(
|
|
|
109
109
|
child_workflow_only: only_child,
|
|
110
110
|
},
|
|
111
111
|
);
|
|
112
|
-
let cmd = Command {
|
|
113
|
-
command_type: CommandType::SignalExternalWorkflowExecution as i32,
|
|
114
|
-
attributes: Some(cmd_attrs),
|
|
115
|
-
user_metadata: Default::default(),
|
|
116
|
-
};
|
|
117
112
|
Ok(NewMachineWithCommand {
|
|
118
|
-
command:
|
|
113
|
+
command: cmd_attrs,
|
|
119
114
|
machine: s.into(),
|
|
120
115
|
})
|
|
121
116
|
}
|
|
@@ -210,7 +205,7 @@ impl TryFrom<HistEventData> for SignalExternalMachineEvents {
|
|
|
210
205
|
_ => {
|
|
211
206
|
return Err(WFMachinesError::Nondeterminism(format!(
|
|
212
207
|
"Signal external WF machine does not handle this event: {e}"
|
|
213
|
-
)))
|
|
208
|
+
)));
|
|
214
209
|
}
|
|
215
210
|
})
|
|
216
211
|
}
|
|
@@ -224,11 +219,13 @@ impl WFMachinesAdapter for SignalExternalMachine {
|
|
|
224
219
|
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
225
220
|
Ok(match my_command {
|
|
226
221
|
SignalExternalCommand::Signaled => {
|
|
227
|
-
vec![
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
222
|
+
vec![
|
|
223
|
+
ResolveSignalExternalWorkflow {
|
|
224
|
+
seq: self.shared_state.seq,
|
|
225
|
+
failure: None,
|
|
226
|
+
}
|
|
227
|
+
.into(),
|
|
228
|
+
]
|
|
232
229
|
}
|
|
233
230
|
SignalExternalCommand::Failed(f) => {
|
|
234
231
|
let reason = match f {
|
|
@@ -240,21 +237,23 @@ impl WFMachinesAdapter for SignalExternalMachine {
|
|
|
240
237
|
"The per-workflow signal limit was exceeded"
|
|
241
238
|
}
|
|
242
239
|
};
|
|
243
|
-
vec![
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
ApplicationFailureInfo
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
240
|
+
vec![
|
|
241
|
+
ResolveSignalExternalWorkflow {
|
|
242
|
+
seq: self.shared_state.seq,
|
|
243
|
+
// TODO: Create new failure type upstream for this
|
|
244
|
+
failure: Some(Failure {
|
|
245
|
+
message: format!("Unable to signal external workflow because {reason}"),
|
|
246
|
+
failure_info: Some(FailureInfo::ApplicationFailureInfo(
|
|
247
|
+
ApplicationFailureInfo {
|
|
248
|
+
r#type: f.to_string(),
|
|
249
|
+
..Default::default()
|
|
250
|
+
},
|
|
251
|
+
)),
|
|
252
|
+
..Default::default()
|
|
253
|
+
}),
|
|
254
|
+
}
|
|
255
|
+
.into(),
|
|
256
|
+
]
|
|
258
257
|
}
|
|
259
258
|
SignalExternalCommand::Cancelled => {
|
|
260
259
|
panic!("Cancelled command not expected as part of non-cancel transition")
|
|
@@ -263,23 +262,25 @@ impl WFMachinesAdapter for SignalExternalMachine {
|
|
|
263
262
|
}
|
|
264
263
|
}
|
|
265
264
|
|
|
266
|
-
impl
|
|
267
|
-
fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<
|
|
265
|
+
impl SignalExternalMachine {
|
|
266
|
+
pub(super) fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<WFMachinesError>> {
|
|
268
267
|
let res = OnEventWrapper::on_event_mut(self, SignalExternalMachineEvents::Cancel)?;
|
|
269
268
|
let mut ret = vec![];
|
|
270
269
|
match res.first() {
|
|
271
270
|
Some(SignalExternalCommand::Cancelled) => {
|
|
272
|
-
ret = vec![
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
271
|
+
ret = vec![
|
|
272
|
+
ResolveSignalExternalWorkflow {
|
|
273
|
+
seq: self.shared_state.seq,
|
|
274
|
+
failure: Some(Failure {
|
|
275
|
+
message: SIG_CANCEL_MSG.to_string(),
|
|
276
|
+
failure_info: Some(FailureInfo::CanceledFailureInfo(
|
|
277
|
+
CanceledFailureInfo { details: None },
|
|
278
|
+
)),
|
|
279
|
+
..Default::default()
|
|
280
|
+
}),
|
|
281
|
+
}
|
|
282
|
+
.into(),
|
|
283
|
+
];
|
|
283
284
|
}
|
|
284
285
|
Some(_) => panic!("Signal external machine cancel produced unexpected result"),
|
|
285
286
|
None => (),
|
|
@@ -287,7 +288,7 @@ impl Cancellable for SignalExternalMachine {
|
|
|
287
288
|
Ok(ret)
|
|
288
289
|
}
|
|
289
290
|
|
|
290
|
-
fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
291
|
+
pub(super) fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
291
292
|
// We are only ever in the cancelled state if cancelled before sent to server, there is no
|
|
292
293
|
// after sent cancellation here.
|
|
293
294
|
matches!(self.state(), SignalExternalMachineState::Cancelled(_))
|
|
@@ -299,13 +300,14 @@ mod tests {
|
|
|
299
300
|
use super::*;
|
|
300
301
|
use crate::{
|
|
301
302
|
replay::TestHistoryBuilder,
|
|
302
|
-
test_help::{
|
|
303
|
+
test_help::{MockPollCfg, build_fake_sdk},
|
|
303
304
|
};
|
|
304
305
|
use std::mem::discriminant;
|
|
305
306
|
use temporal_sdk::{CancellableFuture, SignalWorkflowOptions, WfContext, WorkflowResult};
|
|
306
307
|
use temporal_sdk_core_protos::{
|
|
307
|
-
coresdk::workflow_activation::{workflow_activation_job, WorkflowActivationJob},
|
|
308
308
|
DEFAULT_WORKFLOW_TYPE,
|
|
309
|
+
coresdk::workflow_activation::{WorkflowActivationJob, workflow_activation_job},
|
|
310
|
+
temporal::api::command::v1::Command,
|
|
309
311
|
};
|
|
310
312
|
use temporal_sdk_core_test_utils::interceptors::ActivationAssertionsInterceptor;
|
|
311
313
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#![allow(clippy::large_enum_variant)]
|
|
2
2
|
|
|
3
3
|
use super::{
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
EventInfo, NewMachineWithCommand, OnEventWrapper, WFMachinesAdapter,
|
|
5
|
+
workflow_machines::MachineResponse,
|
|
6
6
|
};
|
|
7
|
-
use crate::worker::workflow::{machines::HistEventData
|
|
8
|
-
use rustfsm::{
|
|
7
|
+
use crate::worker::workflow::{WFMachinesError, machines::HistEventData};
|
|
8
|
+
use rustfsm::{MachineError, StateMachine, TransitionResult, fsm};
|
|
9
9
|
use std::convert::TryFrom;
|
|
10
10
|
use temporal_sdk_core_protos::{
|
|
11
11
|
coresdk::{
|
|
12
|
+
HistoryEventId,
|
|
12
13
|
workflow_activation::FireTimer,
|
|
13
14
|
workflow_commands::{CancelTimer, StartTimer},
|
|
14
|
-
HistoryEventId,
|
|
15
15
|
},
|
|
16
16
|
temporal::api::{
|
|
17
|
-
command::v1::
|
|
17
|
+
command::v1::command,
|
|
18
18
|
enums::v1::{CommandType, EventType},
|
|
19
|
-
history::v1::{
|
|
19
|
+
history::v1::{TimerFiredEventAttributes, history_event},
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -49,7 +49,7 @@ fsm! {
|
|
|
49
49
|
#[derive(Debug, derive_more::Display)]
|
|
50
50
|
pub(super) enum TimerMachineCommand {
|
|
51
51
|
Complete,
|
|
52
|
-
IssueCancelCmd(
|
|
52
|
+
IssueCancelCmd(command::Attributes),
|
|
53
53
|
// We don't issue activations for timer cancellations. Lang SDK is expected to cancel
|
|
54
54
|
// it's own timers when user calls cancel, and they cannot be cancelled by any other
|
|
55
55
|
// means.
|
|
@@ -72,15 +72,11 @@ pub(super) fn new_timer(attribs: StartTimer) -> NewMachineWithCommand {
|
|
|
72
72
|
|
|
73
73
|
impl TimerMachine {
|
|
74
74
|
/// Create a new timer and immediately schedule it
|
|
75
|
-
fn new_scheduled(attribs: StartTimer) -> (Self,
|
|
75
|
+
fn new_scheduled(attribs: StartTimer) -> (Self, command::Attributes) {
|
|
76
76
|
let mut s = Self::new(attribs);
|
|
77
77
|
OnEventWrapper::on_event_mut(&mut s, TimerMachineEvents::Schedule)
|
|
78
78
|
.expect("Scheduling timers doesn't fail");
|
|
79
|
-
let cmd =
|
|
80
|
-
command_type: CommandType::StartTimer as i32,
|
|
81
|
-
attributes: Some(s.shared_state().attrs.into()),
|
|
82
|
-
user_metadata: Default::default(),
|
|
83
|
-
};
|
|
79
|
+
let cmd = s.shared_state().attrs.into();
|
|
84
80
|
(s, cmd)
|
|
85
81
|
}
|
|
86
82
|
|
|
@@ -93,6 +89,22 @@ impl TimerMachine {
|
|
|
93
89
|
},
|
|
94
90
|
)
|
|
95
91
|
}
|
|
92
|
+
|
|
93
|
+
pub(super) fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<WFMachinesError>> {
|
|
94
|
+
Ok(
|
|
95
|
+
match OnEventWrapper::on_event_mut(self, TimerMachineEvents::Cancel)?.pop() {
|
|
96
|
+
Some(TimerMachineCommand::IssueCancelCmd(cmd)) => {
|
|
97
|
+
vec![MachineResponse::IssueNewCommand(cmd.into())]
|
|
98
|
+
}
|
|
99
|
+
None => vec![],
|
|
100
|
+
x => panic!("Invalid cancel event response {x:?}"),
|
|
101
|
+
},
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
pub(super) fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
106
|
+
self.shared_state().cancelled_before_sent
|
|
107
|
+
}
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
impl TryFrom<HistEventData> for TimerMachineEvents {
|
|
@@ -117,7 +129,7 @@ impl TryFrom<HistEventData> for TimerMachineEvents {
|
|
|
117
129
|
_ => {
|
|
118
130
|
return Err(WFMachinesError::Nondeterminism(format!(
|
|
119
131
|
"Timer machine does not handle this event: {e}"
|
|
120
|
-
)))
|
|
132
|
+
)));
|
|
121
133
|
}
|
|
122
134
|
})
|
|
123
135
|
}
|
|
@@ -208,13 +220,10 @@ impl StartCommandRecorded {
|
|
|
208
220
|
self,
|
|
209
221
|
dat: &mut SharedState,
|
|
210
222
|
) -> TimerMachineTransition<CancelTimerCommandCreated> {
|
|
211
|
-
let cmd = Command {
|
|
212
|
-
command_type: CommandType::CancelTimer as i32,
|
|
213
|
-
attributes: Some(CancelTimer { seq: dat.attrs.seq }.into()),
|
|
214
|
-
user_metadata: Default::default(),
|
|
215
|
-
};
|
|
216
223
|
TransitionResult::ok(
|
|
217
|
-
vec![TimerMachineCommand::IssueCancelCmd(
|
|
224
|
+
vec![TimerMachineCommand::IssueCancelCmd(
|
|
225
|
+
CancelTimer { seq: dat.attrs.seq }.into(),
|
|
226
|
+
)],
|
|
218
227
|
CancelTimerCommandCreated::default(),
|
|
219
228
|
)
|
|
220
229
|
}
|
|
@@ -228,45 +237,31 @@ impl WFMachinesAdapter for TimerMachine {
|
|
|
228
237
|
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
229
238
|
Ok(match my_command {
|
|
230
239
|
// Fire the completion
|
|
231
|
-
TimerMachineCommand::Complete => vec![
|
|
232
|
-
|
|
240
|
+
TimerMachineCommand::Complete => vec![
|
|
241
|
+
FireTimer {
|
|
242
|
+
seq: self.shared_state.attrs.seq,
|
|
243
|
+
}
|
|
244
|
+
.into(),
|
|
245
|
+
],
|
|
246
|
+
TimerMachineCommand::IssueCancelCmd(c) => {
|
|
247
|
+
vec![MachineResponse::IssueNewCommand(c.into())]
|
|
233
248
|
}
|
|
234
|
-
.into()],
|
|
235
|
-
TimerMachineCommand::IssueCancelCmd(c) => vec![MachineResponse::IssueNewCommand(c)],
|
|
236
249
|
})
|
|
237
250
|
}
|
|
238
251
|
}
|
|
239
252
|
|
|
240
|
-
impl Cancellable for TimerMachine {
|
|
241
|
-
fn cancel(&mut self) -> Result<Vec<MachineResponse>, MachineError<Self::Error>> {
|
|
242
|
-
Ok(
|
|
243
|
-
match OnEventWrapper::on_event_mut(self, TimerMachineEvents::Cancel)?.pop() {
|
|
244
|
-
Some(TimerMachineCommand::IssueCancelCmd(cmd)) => {
|
|
245
|
-
vec![MachineResponse::IssueNewCommand(cmd)]
|
|
246
|
-
}
|
|
247
|
-
None => vec![],
|
|
248
|
-
x => panic!("Invalid cancel event response {x:?}"),
|
|
249
|
-
},
|
|
250
|
-
)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
fn was_cancelled_before_sent_to_server(&self) -> bool {
|
|
254
|
-
self.shared_state().cancelled_before_sent
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
253
|
#[cfg(test)]
|
|
259
254
|
mod test {
|
|
260
255
|
use super::*;
|
|
261
256
|
use crate::{
|
|
262
257
|
replay::TestHistoryBuilder,
|
|
263
|
-
test_help::{build_fake_sdk, canned_histories
|
|
258
|
+
test_help::{MockPollCfg, build_fake_sdk, canned_histories},
|
|
264
259
|
};
|
|
265
260
|
use std::{mem::discriminant, time::Duration};
|
|
266
261
|
use temporal_sdk::{CancellableFuture, WfContext, WorkflowResult};
|
|
267
262
|
use temporal_sdk_core_protos::{
|
|
268
|
-
temporal::api::{enums::v1::WorkflowTaskFailedCause, failure::v1::Failure},
|
|
269
263
|
DEFAULT_WORKFLOW_TYPE,
|
|
264
|
+
temporal::api::{enums::v1::WorkflowTaskFailedCause, failure::v1::Failure},
|
|
270
265
|
};
|
|
271
266
|
|
|
272
267
|
async fn happy_timer(ctx: WfContext) -> WorkflowResult<()> {
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
//! in stable Rust. Don't do the things in here. They're bad. This is test only code, and should
|
|
4
4
|
//! never ever be removed from behind `#[cfg(test)]` compilation.
|
|
5
5
|
|
|
6
|
-
use dashmap::{mapref::entry::Entry
|
|
6
|
+
use dashmap::{DashMap, DashSet, mapref::entry::Entry};
|
|
7
7
|
use std::sync::LazyLock;
|
|
8
8
|
use std::{
|
|
9
9
|
path::PathBuf,
|
|
10
10
|
sync::{
|
|
11
|
-
mpsc::{sync_channel, SyncSender},
|
|
12
11
|
Mutex,
|
|
12
|
+
mpsc::{SyncSender, sync_channel},
|
|
13
13
|
},
|
|
14
14
|
thread::JoinHandle,
|
|
15
15
|
time::Duration,
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
use super::{
|
|
1
|
+
use super::{EventInfo, WFMachinesAdapter, WFMachinesError, workflow_machines::MachineResponse};
|
|
2
2
|
use crate::{
|
|
3
3
|
protosext::protocol_messages::UpdateRequest,
|
|
4
|
-
worker::workflow::machines::{
|
|
4
|
+
worker::workflow::machines::{HistEventData, NewMachineWithResponse},
|
|
5
5
|
};
|
|
6
6
|
use itertools::Itertools;
|
|
7
7
|
use prost::EncodeError;
|
|
8
|
-
use rustfsm::{
|
|
8
|
+
use rustfsm::{MachineError, StateMachine, TransitionResult, fsm};
|
|
9
9
|
use std::convert::TryFrom;
|
|
10
10
|
use temporal_sdk_core_protos::{
|
|
11
11
|
coresdk::{
|
|
12
12
|
workflow_activation::DoUpdate,
|
|
13
|
-
workflow_commands::{
|
|
13
|
+
workflow_commands::{UpdateResponse, update_response},
|
|
14
14
|
},
|
|
15
15
|
temporal::api::{
|
|
16
|
-
command::v1::{
|
|
16
|
+
command::v1::{ProtocolMessageCommandAttributes, command},
|
|
17
17
|
common::v1::Payload,
|
|
18
18
|
enums::v1::{CommandType, EventType},
|
|
19
19
|
failure::v1::Failure,
|
|
20
20
|
protocol::v1::Message as ProtocolMessage,
|
|
21
21
|
update,
|
|
22
|
-
update::v1::{
|
|
22
|
+
update::v1::{Acceptance, Outcome, Rejection, Response, outcome},
|
|
23
23
|
},
|
|
24
24
|
utilities::pack_any,
|
|
25
25
|
};
|
|
@@ -122,7 +122,7 @@ impl UpdateMachine {
|
|
|
122
122
|
return Err(WFMachinesError::Fatal(format!(
|
|
123
123
|
"Update response for update {} had an empty result, this is a lang layer bug.",
|
|
124
124
|
&self.shared_state.meta.update_id
|
|
125
|
-
)))
|
|
125
|
+
)));
|
|
126
126
|
}
|
|
127
127
|
Some(update_response::Response::Accepted(_)) => {
|
|
128
128
|
self.on_event(UpdateMachineEvents::Accept)
|
|
@@ -223,7 +223,7 @@ impl TryFrom<HistEventData> for UpdateMachineEvents {
|
|
|
223
223
|
_ => {
|
|
224
224
|
return Err(WFMachinesError::Nondeterminism(format!(
|
|
225
225
|
"Update machine does not handle this event: {e}"
|
|
226
|
-
)))
|
|
226
|
+
)));
|
|
227
227
|
}
|
|
228
228
|
})
|
|
229
229
|
}
|
|
@@ -407,5 +407,3 @@ impl From<CompletedImmediatelyAcceptCreated> for CompletedImmediatelyCompleteCre
|
|
|
407
407
|
CompletedImmediatelyCompleteCreated {}
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
|
-
|
|
411
|
-
impl Cancellable for UpdateMachine {}
|
package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
use super::{workflow_machines::MachineResponse
|
|
1
|
+
use super::{NewMachineWithCommand, workflow_machines::MachineResponse};
|
|
2
2
|
use crate::{
|
|
3
3
|
internal_flags::CoreInternalFlags,
|
|
4
4
|
worker::workflow::{
|
|
5
|
+
InternalFlagsRef, WFMachinesError,
|
|
5
6
|
machines::{
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
EventInfo, HistEventData, WFMachinesAdapter,
|
|
8
|
+
patch_state_machine::VERSION_SEARCH_ATTR_KEY,
|
|
8
9
|
},
|
|
9
|
-
InternalFlagsRef, WFMachinesError,
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
|
-
use rustfsm::{
|
|
12
|
+
use rustfsm::{StateMachine, TransitionResult, fsm};
|
|
13
13
|
use temporal_sdk_core_protos::{
|
|
14
14
|
coresdk::workflow_commands::UpsertWorkflowSearchAttributes,
|
|
15
15
|
temporal::api::{
|
|
16
|
-
command::v1::{
|
|
16
|
+
command::v1::{UpsertWorkflowSearchAttributesCommandAttributes, command},
|
|
17
17
|
common::v1::SearchAttributes,
|
|
18
18
|
enums::v1::CommandType,
|
|
19
19
|
history::v1::history_event,
|
|
@@ -77,19 +77,13 @@ pub(super) fn upsert_search_attrs_internal(
|
|
|
77
77
|
|
|
78
78
|
fn create_new(sa_map: SearchAttributes) -> NewMachineWithCommand {
|
|
79
79
|
let sm = UpsertSearchAttributesMachine::from_parts(Created {}.into(), SharedState {});
|
|
80
|
-
let cmd = Command {
|
|
81
|
-
command_type: CommandType::UpsertWorkflowSearchAttributes as i32,
|
|
82
|
-
attributes: Some(
|
|
83
|
-
command::Attributes::UpsertWorkflowSearchAttributesCommandAttributes(
|
|
84
|
-
UpsertWorkflowSearchAttributesCommandAttributes {
|
|
85
|
-
search_attributes: Some(sa_map),
|
|
86
|
-
},
|
|
87
|
-
),
|
|
88
|
-
),
|
|
89
|
-
user_metadata: Default::default(),
|
|
90
|
-
};
|
|
91
80
|
NewMachineWithCommand {
|
|
92
|
-
command:
|
|
81
|
+
command: command::Attributes::UpsertWorkflowSearchAttributesCommandAttributes(
|
|
82
|
+
UpsertWorkflowSearchAttributesCommandAttributes {
|
|
83
|
+
search_attributes: Some(sa_map),
|
|
84
|
+
},
|
|
85
|
+
),
|
|
86
|
+
|
|
93
87
|
machine: sm.into(),
|
|
94
88
|
}
|
|
95
89
|
}
|
|
@@ -140,8 +134,6 @@ impl WFMachinesAdapter for UpsertSearchAttributesMachine {
|
|
|
140
134
|
}
|
|
141
135
|
}
|
|
142
136
|
|
|
143
|
-
impl Cancellable for UpsertSearchAttributesMachine {}
|
|
144
|
-
|
|
145
137
|
// Converts the generic history event with type EventType::UpsertWorkflowSearchAttributes into the
|
|
146
138
|
// UpsertSearchAttributesMachine-specific event type
|
|
147
139
|
// UpsertSearchAttributesMachineEvents::CommandRecorded.
|
|
@@ -189,7 +181,7 @@ mod tests {
|
|
|
189
181
|
use super::{super::OnEventWrapper, *};
|
|
190
182
|
use crate::{
|
|
191
183
|
replay::TestHistoryBuilder,
|
|
192
|
-
test_help::{
|
|
184
|
+
test_help::{MockPollCfg, ResponseType, build_fake_sdk, build_mock_pollers, mock_worker},
|
|
193
185
|
worker::{
|
|
194
186
|
client::mocks::mock_workflow_client,
|
|
195
187
|
workflow::machines::patch_state_machine::VERSION_SEARCH_ATTR_KEY,
|
|
@@ -200,19 +192,19 @@ mod tests {
|
|
|
200
192
|
use temporal_sdk::WfContext;
|
|
201
193
|
use temporal_sdk_core_api::Worker;
|
|
202
194
|
use temporal_sdk_core_protos::{
|
|
195
|
+
DEFAULT_WORKFLOW_TYPE,
|
|
203
196
|
coresdk::{
|
|
204
|
-
|
|
197
|
+
AsJsonPayloadExt,
|
|
198
|
+
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
|
|
205
199
|
workflow_commands::SetPatchMarker,
|
|
206
200
|
workflow_completion::WorkflowActivationCompletion,
|
|
207
|
-
AsJsonPayloadExt,
|
|
208
201
|
},
|
|
209
202
|
temporal::api::{
|
|
210
|
-
command::v1::command::Attributes,
|
|
203
|
+
command::v1::{Command, command::Attributes},
|
|
211
204
|
common::v1::Payload,
|
|
212
205
|
enums::v1::EventType,
|
|
213
206
|
history::v1::{HistoryEvent, UpsertWorkflowSearchAttributesEventAttributes},
|
|
214
207
|
},
|
|
215
|
-
DEFAULT_WORKFLOW_TYPE,
|
|
216
208
|
};
|
|
217
209
|
use temporal_sdk_core_test_utils::WorkerTestHelpers;
|
|
218
210
|
|
|
@@ -369,11 +361,13 @@ mod tests {
|
|
|
369
361
|
);
|
|
370
362
|
let act = core.poll_workflow_activation().await.unwrap();
|
|
371
363
|
let mut cmds = if with_patched_cmd {
|
|
372
|
-
vec![
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
364
|
+
vec![
|
|
365
|
+
SetPatchMarker {
|
|
366
|
+
patch_id,
|
|
367
|
+
deprecated: false,
|
|
368
|
+
}
|
|
369
|
+
.into(),
|
|
370
|
+
]
|
|
377
371
|
} else {
|
|
378
372
|
vec![]
|
|
379
373
|
};
|