@temporalio/core-bridge 1.9.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +754 -473
- package/Cargo.toml +3 -3
- package/lib/index.d.ts +33 -2
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- 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/scripts/build.js +4 -3
- package/sdk-core/.cargo/config.toml +2 -4
- package/sdk-core/.github/workflows/heavy.yml +1 -1
- package/sdk-core/.github/workflows/per-pr.yml +6 -4
- package/sdk-core/Cargo.toml +10 -3
- package/sdk-core/README.md +4 -6
- package/sdk-core/client/Cargo.toml +13 -5
- package/sdk-core/client/src/lib.rs +123 -34
- package/sdk-core/client/src/metrics.rs +70 -18
- package/sdk-core/client/src/proxy.rs +85 -0
- package/sdk-core/client/src/raw.rs +67 -5
- package/sdk-core/client/src/worker_registry/mod.rs +5 -3
- package/sdk-core/client/src/workflow_handle/mod.rs +3 -1
- package/sdk-core/core/Cargo.toml +31 -37
- package/sdk-core/core/src/abstractions/take_cell.rs +3 -3
- package/sdk-core/core/src/abstractions.rs +176 -108
- package/sdk-core/core/src/core_tests/activity_tasks.rs +4 -13
- package/sdk-core/core/src/core_tests/determinism.rs +2 -1
- package/sdk-core/core/src/core_tests/local_activities.rs +3 -3
- package/sdk-core/core/src/core_tests/mod.rs +3 -3
- package/sdk-core/core/src/core_tests/queries.rs +42 -5
- package/sdk-core/core/src/core_tests/workers.rs +2 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +115 -15
- package/sdk-core/core/src/ephemeral_server/mod.rs +109 -136
- package/sdk-core/core/src/internal_flags.rs +8 -8
- package/sdk-core/core/src/lib.rs +16 -11
- package/sdk-core/core/src/pollers/mod.rs +11 -5
- package/sdk-core/core/src/pollers/poll_buffer.rs +48 -29
- package/sdk-core/core/src/protosext/mod.rs +32 -32
- package/sdk-core/core/src/protosext/protocol_messages.rs +14 -24
- package/sdk-core/core/src/retry_logic.rs +2 -2
- package/sdk-core/core/src/telemetry/log_export.rs +10 -9
- package/sdk-core/core/src/telemetry/metrics.rs +233 -330
- package/sdk-core/core/src/telemetry/mod.rs +11 -38
- package/sdk-core/core/src/telemetry/otel.rs +355 -0
- package/sdk-core/core/src/telemetry/prometheus_server.rs +36 -23
- package/sdk-core/core/src/test_help/mod.rs +80 -59
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +6 -6
- package/sdk-core/core/src/worker/activities/local_activities.rs +46 -43
- package/sdk-core/core/src/worker/activities.rs +45 -46
- package/sdk-core/core/src/worker/client/mocks.rs +8 -7
- package/sdk-core/core/src/worker/client.rs +40 -39
- package/sdk-core/core/src/worker/mod.rs +72 -42
- package/sdk-core/core/src/worker/slot_provider.rs +28 -28
- package/sdk-core/core/src/worker/slot_supplier.rs +1 -0
- package/sdk-core/core/src/worker/tuner/fixed_size.rs +52 -0
- package/sdk-core/core/src/worker/tuner/resource_based.rs +561 -0
- package/sdk-core/core/src/worker/tuner.rs +122 -0
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +6 -6
- package/sdk-core/core/src/worker/workflow/history_update.rs +27 -53
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +4 -17
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -10
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +4 -11
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +17 -35
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -8
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +1 -5
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -14
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -5
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -10
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +3 -10
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +12 -8
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +0 -10
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -13
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +27 -37
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +3 -14
- package/sdk-core/core/src/worker/workflow/managed_run.rs +84 -54
- package/sdk-core/core/src/worker/workflow/mod.rs +63 -160
- package/sdk-core/core/src/worker/workflow/run_cache.rs +22 -13
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +16 -3
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +15 -12
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +39 -78
- package/sdk-core/core-api/Cargo.toml +6 -5
- package/sdk-core/core-api/src/errors.rs +8 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +75 -4
- package/sdk-core/core-api/src/telemetry.rs +7 -1
- package/sdk-core/core-api/src/worker.rs +212 -56
- package/sdk-core/fsm/Cargo.toml +3 -0
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- package/sdk-core/sdk/Cargo.toml +5 -7
- package/sdk-core/sdk/src/app_data.rs +3 -3
- package/sdk-core/sdk/src/lib.rs +5 -3
- package/sdk-core/sdk/src/workflow_context/options.rs +1 -1
- package/sdk-core/sdk/src/workflow_context.rs +10 -9
- package/sdk-core/sdk/src/workflow_future.rs +1 -1
- package/sdk-core/sdk-core-protos/Cargo.toml +8 -6
- package/sdk-core/sdk-core-protos/build.rs +1 -10
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +3 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/ci.yml +26 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +42 -20
- package/sdk-core/sdk-core-protos/protos/api_upstream/README.md +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/api-linter.yaml +36 -26
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.lock +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/google/protobuf/struct.proto +95 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +9632 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +7337 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/payload_description.txt +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +45 -11
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +22 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/command_type.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +44 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +18 -3
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +30 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/update.proto +7 -8
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +23 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +25 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +141 -15
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +12 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +193 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +73 -6
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +46 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +4 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +116 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +134 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +274 -29
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +57 -1
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +10 -12
- package/sdk-core/sdk-core-protos/src/history_builder.rs +1 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +54 -51
- package/sdk-core/sdk-core-protos/src/task_token.rs +11 -2
- package/sdk-core/test-utils/Cargo.toml +7 -4
- package/sdk-core/test-utils/src/histfetch.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +44 -62
- package/sdk-core/tests/fuzzy_workflow.rs +5 -2
- package/sdk-core/tests/heavy_tests.rs +114 -17
- package/sdk-core/tests/integ_tests/activity_functions.rs +1 -1
- package/sdk-core/tests/integ_tests/client_tests.rs +2 -2
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +38 -26
- package/sdk-core/tests/integ_tests/metrics_tests.rs +126 -17
- package/sdk-core/tests/integ_tests/polling_tests.rs +118 -2
- package/sdk-core/tests/integ_tests/update_tests.rs +3 -5
- package/sdk-core/tests/integ_tests/visibility_tests.rs +3 -3
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +3 -3
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +5 -4
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -2
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +6 -10
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +9 -7
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +14 -9
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +6 -13
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +9 -6
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +5 -5
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests.rs +115 -11
- package/sdk-core/tests/main.rs +2 -2
- package/src/conversions.rs +57 -0
- package/src/lib.rs +1 -0
- package/src/runtime.rs +51 -35
- package/ts/index.ts +67 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
- package/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
- package/sdk-core/sdk/src/payload_converter.rs +0 -11
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/Dockerfile +0 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/docker-compose.yml +0 -15
- package/sdk-core/sdk-core-protos/protos/api_upstream/.buildkite/pipeline.yml +0 -10
- package/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
- package/sdk-core/tests/wf_input_replay.rs +0 -32
|
@@ -46,7 +46,6 @@ use temporal_sdk_core_protos::{
|
|
|
46
46
|
},
|
|
47
47
|
common::v1::SearchAttributes,
|
|
48
48
|
enums::v1::CommandType,
|
|
49
|
-
history::v1::HistoryEvent,
|
|
50
49
|
},
|
|
51
50
|
};
|
|
52
51
|
|
|
@@ -237,10 +236,6 @@ impl WFMachinesAdapter for PatchMachine {
|
|
|
237
236
|
) -> Result<Vec<MachineResponse>, WFMachinesError> {
|
|
238
237
|
panic!("Patch machine does not produce commands")
|
|
239
238
|
}
|
|
240
|
-
|
|
241
|
-
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
242
|
-
event.get_patch_marker_details().is_some()
|
|
243
|
-
}
|
|
244
239
|
}
|
|
245
240
|
|
|
246
241
|
impl Cancellable for PatchMachine {}
|
|
@@ -19,7 +19,7 @@ use temporal_sdk_core_protos::{
|
|
|
19
19
|
common::v1::WorkflowExecution as UpstreamWE,
|
|
20
20
|
enums::v1::{CommandType, EventType, SignalExternalWorkflowExecutionFailedCause},
|
|
21
21
|
failure::v1::{failure::FailureInfo, ApplicationFailureInfo, CanceledFailureInfo, Failure},
|
|
22
|
-
history::v1::
|
|
22
|
+
history::v1::history_event,
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -260,15 +260,6 @@ impl WFMachinesAdapter for SignalExternalMachine {
|
|
|
260
260
|
}
|
|
261
261
|
})
|
|
262
262
|
}
|
|
263
|
-
|
|
264
|
-
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
265
|
-
matches!(
|
|
266
|
-
event.event_type(),
|
|
267
|
-
EventType::ExternalWorkflowExecutionSignaled
|
|
268
|
-
| EventType::SignalExternalWorkflowExecutionInitiated
|
|
269
|
-
| EventType::SignalExternalWorkflowExecutionFailed
|
|
270
|
-
)
|
|
271
|
-
}
|
|
272
263
|
}
|
|
273
264
|
|
|
274
265
|
impl Cancellable for SignalExternalMachine {
|
|
@@ -16,7 +16,7 @@ use temporal_sdk_core_protos::{
|
|
|
16
16
|
temporal::api::{
|
|
17
17
|
command::v1::Command,
|
|
18
18
|
enums::v1::{CommandType, EventType},
|
|
19
|
-
history::v1::{history_event,
|
|
19
|
+
history::v1::{history_event, TimerFiredEventAttributes},
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -233,13 +233,6 @@ impl WFMachinesAdapter for TimerMachine {
|
|
|
233
233
|
TimerMachineCommand::IssueCancelCmd(c) => vec![MachineResponse::IssueNewCommand(c)],
|
|
234
234
|
})
|
|
235
235
|
}
|
|
236
|
-
|
|
237
|
-
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
238
|
-
matches!(
|
|
239
|
-
event.event_type(),
|
|
240
|
-
EventType::TimerStarted | EventType::TimerCanceled | EventType::TimerFired
|
|
241
|
-
)
|
|
242
|
-
}
|
|
243
236
|
}
|
|
244
237
|
|
|
245
238
|
impl Cancellable for TimerMachine {
|
|
@@ -310,8 +303,8 @@ mod test {
|
|
|
310
303
|
mock_cfg.num_expected_fails = 1;
|
|
311
304
|
mock_cfg.expect_fail_wft_matcher = Box::new(move |_, cause, f| {
|
|
312
305
|
matches!(cause, WorkflowTaskFailedCause::NonDeterministicError)
|
|
313
|
-
&& matches!(f, Some(Failure {
|
|
314
|
-
if
|
|
306
|
+
&& matches!(f, Some(Failure {message, .. })
|
|
307
|
+
if message.contains("Timer fired event did not have expected timer id 1"))
|
|
315
308
|
});
|
|
316
309
|
let mut worker = build_fake_sdk(mock_cfg);
|
|
317
310
|
worker.register_wf(DEFAULT_WORKFLOW_TYPE, |ctx: WfContext| async move {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
//! never ever be removed from behind `#[cfg(test)]` compilation.
|
|
5
5
|
|
|
6
6
|
use dashmap::{mapref::entry::Entry, DashMap, DashSet};
|
|
7
|
+
use once_cell::sync::Lazy;
|
|
7
8
|
use std::{
|
|
8
9
|
path::PathBuf,
|
|
9
10
|
sync::{
|
|
@@ -15,13 +16,11 @@ use std::{
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
// During test we want to know about which transitions we've covered in state machines
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static ref THREAD_HANDLE: Mutex<Option<JoinHandle<()>>> = Mutex::new(None);
|
|
24
|
-
}
|
|
19
|
+
static COVERED_TRANSITIONS: Lazy<DashMap<String, DashSet<CoveredTransition>>> =
|
|
20
|
+
Lazy::new(DashMap::new);
|
|
21
|
+
static COVERAGE_SENDER: Lazy<SyncSender<(String, CoveredTransition)>> =
|
|
22
|
+
Lazy::new(spawn_save_coverage_at_end);
|
|
23
|
+
static THREAD_HANDLE: Lazy<Mutex<Option<JoinHandle<()>>>> = Lazy::new(|| Mutex::new(None));
|
|
25
24
|
|
|
26
25
|
#[derive(Eq, PartialEq, Hash, Debug)]
|
|
27
26
|
struct CoveredTransition {
|
|
@@ -30,7 +29,12 @@ struct CoveredTransition {
|
|
|
30
29
|
event: String,
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
pub fn add_coverage(
|
|
32
|
+
pub(super) fn add_coverage(
|
|
33
|
+
machine_name: String,
|
|
34
|
+
from_state: String,
|
|
35
|
+
to_state: String,
|
|
36
|
+
event: String,
|
|
37
|
+
) {
|
|
34
38
|
let ct = CoveredTransition {
|
|
35
39
|
from_state,
|
|
36
40
|
to_state,
|
|
@@ -17,7 +17,6 @@ use temporal_sdk_core_protos::{
|
|
|
17
17
|
common::v1::Payload,
|
|
18
18
|
enums::v1::{CommandType, EventType},
|
|
19
19
|
failure::v1::Failure,
|
|
20
|
-
history::v1::HistoryEvent,
|
|
21
20
|
protocol::v1::Message as ProtocolMessage,
|
|
22
21
|
update::v1::{outcome, Acceptance, Outcome, Rejection, Response},
|
|
23
22
|
},
|
|
@@ -271,15 +270,6 @@ impl WFMachinesAdapter for UpdateMachine {
|
|
|
271
270
|
)?,
|
|
272
271
|
})
|
|
273
272
|
}
|
|
274
|
-
|
|
275
|
-
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
276
|
-
matches!(
|
|
277
|
-
event.event_type(),
|
|
278
|
-
EventType::WorkflowExecutionUpdateAccepted
|
|
279
|
-
| EventType::WorkflowExecutionUpdateRejected
|
|
280
|
-
| EventType::WorkflowExecutionUpdateCompleted
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
273
|
}
|
|
284
274
|
|
|
285
275
|
impl TryFrom<CommandType> for UpdateMachineEvents {
|
package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs
CHANGED
|
@@ -15,8 +15,8 @@ use temporal_sdk_core_protos::{
|
|
|
15
15
|
temporal::api::{
|
|
16
16
|
command::v1::{command, Command, UpsertWorkflowSearchAttributesCommandAttributes},
|
|
17
17
|
common::v1::SearchAttributes,
|
|
18
|
-
enums::v1::
|
|
19
|
-
history::v1::
|
|
18
|
+
enums::v1::CommandType,
|
|
19
|
+
history::v1::history_event,
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -137,14 +137,6 @@ impl WFMachinesAdapter for UpsertSearchAttributesMachine {
|
|
|
137
137
|
"UpsertWorkflowSearchAttributesMachine does not use commands".to_string(),
|
|
138
138
|
))
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
/// Filters for EventType::UpsertWorkflowSearchAttributes
|
|
142
|
-
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
143
|
-
matches!(
|
|
144
|
-
event.event_type(),
|
|
145
|
-
EventType::UpsertWorkflowSearchAttributes
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
140
|
}
|
|
149
141
|
|
|
150
142
|
impl Cancellable for UpsertSearchAttributesMachine {}
|
|
@@ -214,8 +206,10 @@ mod tests {
|
|
|
214
206
|
AsJsonPayloadExt,
|
|
215
207
|
},
|
|
216
208
|
temporal::api::{
|
|
217
|
-
command::v1::command::Attributes,
|
|
218
|
-
|
|
209
|
+
command::v1::command::Attributes,
|
|
210
|
+
common::v1::Payload,
|
|
211
|
+
enums::v1::EventType,
|
|
212
|
+
history::v1::{HistoryEvent, UpsertWorkflowSearchAttributesEventAttributes},
|
|
219
213
|
},
|
|
220
214
|
DEFAULT_WORKFLOW_TYPE,
|
|
221
215
|
};
|
|
@@ -291,7 +285,6 @@ mod tests {
|
|
|
291
285
|
),
|
|
292
286
|
..Default::default()
|
|
293
287
|
};
|
|
294
|
-
assert!(sm.matches_event(&recorded_history_event));
|
|
295
288
|
let cmd_recorded_sm_event = HistEventData {
|
|
296
289
|
event: recorded_history_event,
|
|
297
290
|
replaying: false,
|
|
@@ -92,18 +92,18 @@ pub(crate) struct WorkflowMachines {
|
|
|
92
92
|
/// The event id of the most recent event processed. It's possible in some situations (ex legacy
|
|
93
93
|
/// queries) to receive a history with no new workflow tasks. If the last history we processed
|
|
94
94
|
/// also had no new tasks, we need a way to know not to apply the same events over again.
|
|
95
|
-
pub last_processed_event: i64,
|
|
95
|
+
pub(crate) last_processed_event: i64,
|
|
96
96
|
/// True if the workflow is replaying from history
|
|
97
|
-
pub replaying: bool,
|
|
97
|
+
pub(crate) replaying: bool,
|
|
98
98
|
/// Workflow identifier
|
|
99
|
-
pub workflow_id: String,
|
|
99
|
+
pub(crate) workflow_id: String,
|
|
100
100
|
/// Workflow type identifier. (Function name, class, etc)
|
|
101
|
-
pub workflow_type: String,
|
|
101
|
+
pub(crate) workflow_type: String,
|
|
102
102
|
/// Identifies the current run
|
|
103
|
-
pub run_id: String,
|
|
103
|
+
pub(crate) run_id: String,
|
|
104
104
|
/// Is set to true once we've seen the final event in workflow history, to avoid accidentally
|
|
105
105
|
/// re-applying the final workflow task.
|
|
106
|
-
pub have_seen_terminal_event: bool,
|
|
106
|
+
pub(crate) have_seen_terminal_event: bool,
|
|
107
107
|
/// The time the workflow execution began, as told by the WEStarted event
|
|
108
108
|
workflow_start_time: Option<SystemTime>,
|
|
109
109
|
/// The time the workflow execution finished, as determined by when the machines handled
|
|
@@ -157,7 +157,7 @@ pub(crate) struct WorkflowMachines {
|
|
|
157
157
|
drive_me: DrivenWorkflow,
|
|
158
158
|
|
|
159
159
|
/// Metrics context
|
|
160
|
-
pub metrics: MetricsContext,
|
|
160
|
+
pub(crate) metrics: MetricsContext,
|
|
161
161
|
worker_config: Arc<WorkerConfig>,
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -376,7 +376,6 @@ impl WorkflowMachines {
|
|
|
376
376
|
has_pending_jobs: self.has_pending_jobs(),
|
|
377
377
|
have_seen_terminal_event: self.have_seen_terminal_event,
|
|
378
378
|
have_pending_la_resolutions: self.has_pending_la_resolutions(),
|
|
379
|
-
last_processed_event: self.last_processed_event,
|
|
380
379
|
me: self,
|
|
381
380
|
}
|
|
382
381
|
}
|
|
@@ -782,7 +781,7 @@ impl WorkflowMachines {
|
|
|
782
781
|
};
|
|
783
782
|
}
|
|
784
783
|
if event.event_type() == EventType::Unspecified
|
|
785
|
-
|| event.event_type() == EventType::
|
|
784
|
+
|| event.event_type() == EventType::WorkflowExecutionUpdateAdmitted
|
|
786
785
|
|| event.attributes.is_none()
|
|
787
786
|
{
|
|
788
787
|
return if !event.worker_may_ignore {
|
|
@@ -905,8 +904,8 @@ impl WorkflowMachines {
|
|
|
905
904
|
fn handle_non_stateful_event(&mut self, event_dat: HistEventData) -> Result<()> {
|
|
906
905
|
trace!(event = %event_dat.event, "handling non-stateful event");
|
|
907
906
|
let event_id = event_dat.event.event_id;
|
|
908
|
-
match EventType::
|
|
909
|
-
|
|
907
|
+
match EventType::try_from(event_dat.event.event_type) {
|
|
908
|
+
Ok(EventType::WorkflowExecutionStarted) => {
|
|
910
909
|
if let Some(history_event::Attributes::WorkflowExecutionStartedEventAttributes(
|
|
911
910
|
attrs,
|
|
912
911
|
)) = event_dat.event.attributes
|
|
@@ -932,13 +931,13 @@ impl WorkflowMachines {
|
|
|
932
931
|
)));
|
|
933
932
|
}
|
|
934
933
|
}
|
|
935
|
-
|
|
934
|
+
Ok(EventType::WorkflowTaskScheduled) => {
|
|
936
935
|
let wf_task_sm = WorkflowTaskMachine::new(self.next_started_event_id);
|
|
937
936
|
let key = self.all_machines.insert(wf_task_sm.into());
|
|
938
937
|
self.submachine_handle_event(key, event_dat)?;
|
|
939
938
|
self.machines_by_event_id.insert(event_id, key);
|
|
940
939
|
}
|
|
941
|
-
|
|
940
|
+
Ok(EventType::WorkflowExecutionSignaled) => {
|
|
942
941
|
if let Some(history_event::Attributes::WorkflowExecutionSignaledEventAttributes(
|
|
943
942
|
attrs,
|
|
944
943
|
)) = event_dat.event.attributes
|
|
@@ -949,7 +948,7 @@ impl WorkflowMachines {
|
|
|
949
948
|
// err
|
|
950
949
|
}
|
|
951
950
|
}
|
|
952
|
-
|
|
951
|
+
Ok(EventType::WorkflowExecutionCancelRequested) => {
|
|
953
952
|
if let Some(
|
|
954
953
|
history_event::Attributes::WorkflowExecutionCancelRequestedEventAttributes(
|
|
955
954
|
attrs,
|
|
@@ -1293,21 +1292,12 @@ impl WorkflowMachines {
|
|
|
1293
1292
|
self.process_cancellation(CommandID::LocalActivity(attrs.seq))?;
|
|
1294
1293
|
}
|
|
1295
1294
|
WFCommand::CompleteWorkflow(attrs) => {
|
|
1296
|
-
if !self.replaying {
|
|
1297
|
-
self.metrics.wf_completed();
|
|
1298
|
-
}
|
|
1299
1295
|
self.add_terminal_command(complete_workflow(attrs));
|
|
1300
1296
|
}
|
|
1301
1297
|
WFCommand::FailWorkflow(attrs) => {
|
|
1302
|
-
if !self.replaying {
|
|
1303
|
-
self.metrics.wf_failed();
|
|
1304
|
-
}
|
|
1305
1298
|
self.add_terminal_command(fail_workflow(attrs));
|
|
1306
1299
|
}
|
|
1307
1300
|
WFCommand::ContinueAsNew(attrs) => {
|
|
1308
|
-
if !self.replaying {
|
|
1309
|
-
self.metrics.wf_continued_as_new();
|
|
1310
|
-
}
|
|
1311
1301
|
let attrs = self.augment_continue_as_new_with_current_values(attrs);
|
|
1312
1302
|
let use_compat = self.determine_use_compatible_flag(
|
|
1313
1303
|
attrs.versioning_intent(),
|
|
@@ -1316,9 +1306,6 @@ impl WorkflowMachines {
|
|
|
1316
1306
|
self.add_terminal_command(continue_as_new(attrs, use_compat));
|
|
1317
1307
|
}
|
|
1318
1308
|
WFCommand::CancelWorkflow(attrs) => {
|
|
1319
|
-
if !self.replaying {
|
|
1320
|
-
self.metrics.wf_canceled();
|
|
1321
|
-
}
|
|
1322
1309
|
self.add_terminal_command(cancel_workflow(attrs));
|
|
1323
1310
|
}
|
|
1324
1311
|
WFCommand::SetPatchMarker(attrs) => {
|
|
@@ -1535,7 +1522,7 @@ impl WorkflowMachines {
|
|
|
1535
1522
|
.unwrap_or_default();
|
|
1536
1523
|
}
|
|
1537
1524
|
if attrs.retry_policy.is_none() {
|
|
1538
|
-
attrs.retry_policy
|
|
1525
|
+
attrs.retry_policy.clone_from(&started_info.retry_policy);
|
|
1539
1526
|
}
|
|
1540
1527
|
}
|
|
1541
1528
|
attrs
|
|
@@ -1560,25 +1547,28 @@ impl WorkflowMachines {
|
|
|
1560
1547
|
/// Contains everything workflow machine internals need to bubble up when we're getting ready to
|
|
1561
1548
|
/// respond with a WFT completion. Allows for lazy mutation of the machine, since mutation is not
|
|
1562
1549
|
/// desired unless we are actually going to respond to the WFT, which may not always happen.
|
|
1563
|
-
pub struct MachinesWFTResponseContent<'a> {
|
|
1550
|
+
pub(crate) struct MachinesWFTResponseContent<'a> {
|
|
1564
1551
|
me: &'a mut WorkflowMachines,
|
|
1565
|
-
pub replaying: bool,
|
|
1566
|
-
pub has_pending_jobs: bool,
|
|
1567
|
-
pub have_seen_terminal_event: bool,
|
|
1568
|
-
pub have_pending_la_resolutions: bool,
|
|
1569
|
-
pub last_processed_event: i64,
|
|
1552
|
+
pub(crate) replaying: bool,
|
|
1553
|
+
pub(crate) has_pending_jobs: bool,
|
|
1554
|
+
pub(crate) have_seen_terminal_event: bool,
|
|
1555
|
+
pub(crate) have_pending_la_resolutions: bool,
|
|
1570
1556
|
}
|
|
1557
|
+
|
|
1571
1558
|
impl<'a> MachinesWFTResponseContent<'a> {
|
|
1572
|
-
pub fn commands(&self) -> Peekable<impl Iterator<Item = ProtoCommand> + '_> {
|
|
1559
|
+
pub(crate) fn commands(&self) -> Peekable<impl Iterator<Item = ProtoCommand> + '_> {
|
|
1573
1560
|
self.me.get_commands().peekable()
|
|
1574
1561
|
}
|
|
1575
|
-
|
|
1562
|
+
|
|
1563
|
+
pub(crate) fn has_messages(&self) -> bool {
|
|
1576
1564
|
!self.me.message_outbox.is_empty()
|
|
1577
1565
|
}
|
|
1578
|
-
|
|
1566
|
+
|
|
1567
|
+
pub(crate) fn messages(&mut self) -> Vec<ProtocolMessage> {
|
|
1579
1568
|
self.me.message_outbox.drain(..).collect()
|
|
1580
1569
|
}
|
|
1581
|
-
|
|
1570
|
+
|
|
1571
|
+
pub(crate) fn metadata_for_complete(&mut self) -> WorkflowTaskCompletedMetadata {
|
|
1582
1572
|
self.me.get_metadata_for_wft_complete()
|
|
1583
1573
|
}
|
|
1584
1574
|
}
|
|
@@ -11,7 +11,7 @@ use std::{
|
|
|
11
11
|
};
|
|
12
12
|
use temporal_sdk_core_protos::temporal::api::{
|
|
13
13
|
enums::v1::{CommandType, EventType, WorkflowTaskFailedCause},
|
|
14
|
-
history::v1::
|
|
14
|
+
history::v1::history_event::Attributes::WorkflowTaskFailedEventAttributes,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
fsm! {
|
|
@@ -88,17 +88,6 @@ impl WFMachinesAdapter for WorkflowTaskMachine {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
fn matches_event(&self, event: &HistoryEvent) -> bool {
|
|
93
|
-
matches!(
|
|
94
|
-
event.event_type(),
|
|
95
|
-
EventType::WorkflowTaskScheduled
|
|
96
|
-
| EventType::WorkflowTaskStarted
|
|
97
|
-
| EventType::WorkflowTaskTimedOut
|
|
98
|
-
| EventType::WorkflowTaskCompleted
|
|
99
|
-
| EventType::WorkflowTaskFailed
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
91
|
}
|
|
103
92
|
|
|
104
93
|
impl TryFrom<HistEventData> for WorkflowTaskMachineEvents {
|
|
@@ -136,9 +125,9 @@ impl TryFrom<HistEventData> for WorkflowTaskMachineEvents {
|
|
|
136
125
|
Self::WorkflowTaskFailed(WFTFailedDat {
|
|
137
126
|
new_run_id: match attributes {
|
|
138
127
|
WorkflowTaskFailedEventAttributes(a) => {
|
|
139
|
-
let cause = WorkflowTaskFailedCause::
|
|
128
|
+
let cause = WorkflowTaskFailedCause::try_from(a.cause);
|
|
140
129
|
match cause {
|
|
141
|
-
|
|
130
|
+
Ok(WorkflowTaskFailedCause::ResetWorkflow) => {
|
|
142
131
|
Some(a.new_run_id)
|
|
143
132
|
}
|
|
144
133
|
_ => None,
|