@temporalio/core-bridge 1.5.2 → 1.7.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 +304 -112
- package/lib/index.d.ts +8 -6
- package/lib/index.js.map +1 -1
- package/package.json +9 -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/sdk-core/.buildkite/docker/Dockerfile +2 -2
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.buildkite/pipeline.yml +2 -4
- package/sdk-core/.cargo/config.toml +5 -2
- package/sdk-core/.github/workflows/heavy.yml +29 -0
- package/sdk-core/Cargo.toml +1 -1
- package/sdk-core/README.md +20 -10
- package/sdk-core/client/src/lib.rs +215 -39
- package/sdk-core/client/src/metrics.rs +17 -8
- package/sdk-core/client/src/raw.rs +4 -4
- package/sdk-core/client/src/retry.rs +32 -20
- package/sdk-core/core/Cargo.toml +25 -12
- package/sdk-core/core/src/abstractions/take_cell.rs +28 -0
- package/sdk-core/core/src/abstractions.rs +204 -14
- package/sdk-core/core/src/core_tests/activity_tasks.rs +143 -50
- package/sdk-core/core/src/core_tests/child_workflows.rs +6 -5
- package/sdk-core/core/src/core_tests/determinism.rs +165 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +431 -43
- package/sdk-core/core/src/core_tests/queries.rs +34 -16
- package/sdk-core/core/src/core_tests/workers.rs +8 -5
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +588 -55
- package/sdk-core/core/src/ephemeral_server/mod.rs +113 -12
- package/sdk-core/core/src/internal_flags.rs +155 -0
- package/sdk-core/core/src/lib.rs +16 -9
- package/sdk-core/core/src/protosext/mod.rs +1 -1
- package/sdk-core/core/src/replay/mod.rs +16 -27
- package/sdk-core/core/src/telemetry/log_export.rs +1 -1
- package/sdk-core/core/src/telemetry/metrics.rs +69 -35
- package/sdk-core/core/src/telemetry/mod.rs +60 -21
- package/sdk-core/core/src/telemetry/prometheus_server.rs +19 -13
- package/sdk-core/core/src/test_help/mod.rs +73 -14
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +119 -160
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- package/sdk-core/core/src/worker/activities/local_activities.rs +379 -129
- package/sdk-core/core/src/worker/activities.rs +350 -175
- package/sdk-core/core/src/worker/client/mocks.rs +22 -2
- package/sdk-core/core/src/worker/client.rs +18 -2
- package/sdk-core/core/src/worker/mod.rs +183 -64
- package/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +3 -5
- package/sdk-core/core/src/worker/workflow/history_update.rs +916 -277
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +216 -183
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +9 -12
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +7 -9
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +160 -87
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -14
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -9
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +14 -17
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +242 -110
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +27 -19
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +9 -11
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +321 -206
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +13 -18
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +20 -29
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +257 -51
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +310 -150
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +17 -20
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +31 -15
- package/sdk-core/core/src/worker/workflow/managed_run.rs +1052 -380
- package/sdk-core/core/src/worker/workflow/mod.rs +598 -390
- package/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +137 -0
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +1 -4
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +469 -718
- package/sdk-core/core-api/Cargo.toml +2 -1
- package/sdk-core/core-api/src/errors.rs +1 -34
- package/sdk-core/core-api/src/lib.rs +19 -9
- package/sdk-core/core-api/src/telemetry.rs +4 -6
- package/sdk-core/core-api/src/worker.rs +19 -1
- package/sdk-core/etc/deps.svg +115 -140
- package/sdk-core/etc/regen-depgraph.sh +5 -0
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +86 -61
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +29 -71
- package/sdk-core/histories/ends_empty_wft_complete.bin +0 -0
- package/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
- package/sdk-core/histories/old_change_marker_format.bin +0 -0
- package/sdk-core/protos/api_upstream/.github/CODEOWNERS +2 -1
- package/sdk-core/protos/api_upstream/Makefile +6 -6
- package/sdk-core/protos/api_upstream/build/go.mod +7 -0
- package/sdk-core/protos/api_upstream/build/go.sum +5 -0
- package/sdk-core/protos/api_upstream/build/tools.go +29 -0
- package/sdk-core/protos/api_upstream/go.mod +6 -0
- package/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +9 -2
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +7 -26
- package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +3 -7
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +8 -8
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +25 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +24 -19
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +49 -26
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +4 -2
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +5 -2
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +57 -0
- package/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +71 -6
- package/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +2 -2
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +64 -28
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +4 -4
- package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +7 -8
- package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +10 -7
- package/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +19 -30
- package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +8 -0
- package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +67 -60
- package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +85 -84
- package/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +9 -3
- package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- package/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- package/sdk-core/sdk/Cargo.toml +5 -4
- package/sdk-core/sdk/src/lib.rs +108 -26
- package/sdk-core/sdk/src/workflow_context/options.rs +7 -1
- package/sdk-core/sdk/src/workflow_context.rs +24 -17
- package/sdk-core/sdk/src/workflow_future.rs +16 -15
- package/sdk-core/sdk-core-protos/Cargo.toml +5 -2
- package/sdk-core/sdk-core-protos/build.rs +36 -2
- package/sdk-core/sdk-core-protos/src/history_builder.rs +138 -106
- package/sdk-core/sdk-core-protos/src/history_info.rs +10 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +272 -87
- package/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
- package/sdk-core/test-utils/Cargo.toml +3 -1
- package/sdk-core/test-utils/src/canned_histories.rs +106 -296
- package/sdk-core/test-utils/src/histfetch.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +82 -23
- package/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
- package/sdk-core/test-utils/src/workflows.rs +29 -0
- package/sdk-core/tests/fuzzy_workflow.rs +130 -0
- package/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +10 -5
- package/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
- package/sdk-core/tests/integ_tests/polling_tests.rs +4 -47
- package/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
- package/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +161 -72
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +80 -3
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +94 -200
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +2 -4
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +34 -28
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +76 -7
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +7 -8
- package/sdk-core/tests/integ_tests/workflow_tests.rs +13 -14
- package/sdk-core/tests/main.rs +3 -13
- package/sdk-core/tests/runner.rs +75 -36
- package/sdk-core/tests/wf_input_replay.rs +32 -0
- package/src/conversions.rs +14 -8
- package/src/runtime.rs +9 -8
- package/ts/index.ts +8 -6
- package/sdk-core/bridge-ffi/Cargo.toml +0 -24
- package/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- package/sdk-core/bridge-ffi/build.rs +0 -25
- package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -224
- package/sdk-core/bridge-ffi/src/lib.rs +0 -746
- package/sdk-core/bridge-ffi/src/wrappers.rs +0 -221
- package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- package/sdk-core/sdk/src/conversions.rs +0 -8
|
@@ -6,10 +6,13 @@ use crate::{
|
|
|
6
6
|
NamespacedWorkflowExecution,
|
|
7
7
|
},
|
|
8
8
|
external_data::LocalActivityMarkerData,
|
|
9
|
-
|
|
9
|
+
workflow_commands::ScheduleActivity,
|
|
10
|
+
AsJsonPayloadExt, IntoPayloadsExt,
|
|
10
11
|
},
|
|
11
12
|
temporal::api::{
|
|
12
|
-
common::v1::{
|
|
13
|
+
common::v1::{
|
|
14
|
+
ActivityType, Payload, Payloads, SearchAttributes, WorkflowExecution, WorkflowType,
|
|
15
|
+
},
|
|
13
16
|
enums::v1::{EventType, TaskQueueKind, WorkflowTaskFailedCause},
|
|
14
17
|
failure::v1::{failure, CanceledFailureInfo, Failure},
|
|
15
18
|
history::v1::{history_event::Attributes, *},
|
|
@@ -18,11 +21,15 @@ use crate::{
|
|
|
18
21
|
HistoryInfo,
|
|
19
22
|
};
|
|
20
23
|
use anyhow::bail;
|
|
21
|
-
use
|
|
22
|
-
use std::
|
|
24
|
+
use prost_wkt_types::Timestamp;
|
|
25
|
+
use std::{
|
|
26
|
+
collections::HashMap,
|
|
27
|
+
time::{Duration, SystemTime},
|
|
28
|
+
};
|
|
23
29
|
use uuid::Uuid;
|
|
24
30
|
|
|
25
31
|
pub static DEFAULT_WORKFLOW_TYPE: &str = "default_wf_type";
|
|
32
|
+
pub static DEFAULT_ACTIVITY_TYPE: &str = "default_act_type";
|
|
26
33
|
|
|
27
34
|
type Result<T, E = anyhow::Error> = std::result::Result<T, E>;
|
|
28
35
|
|
|
@@ -61,26 +68,19 @@ impl TestHistoryBuilder {
|
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
/// Add an event by type with attributes. Bundles both into a [HistoryEvent] with an id that is
|
|
64
|
-
/// incremented on each call to add.
|
|
65
|
-
pub fn add(&mut self,
|
|
66
|
-
|
|
71
|
+
/// incremented on each call to add. Returns the id of the new event.
|
|
72
|
+
pub fn add(&mut self, attribs: impl Into<Attributes>) -> i64 {
|
|
73
|
+
let attribs: Attributes = attribs.into();
|
|
74
|
+
self.build_and_push_event(attribs.event_type(), attribs);
|
|
75
|
+
self.current_event_id
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
/// Adds an event to the history by type, with default attributes.
|
|
70
|
-
|
|
78
|
+
/// Adds an event to the history by type, with default attributes. Returns the id of the new
|
|
79
|
+
/// event.
|
|
80
|
+
pub fn add_by_type(&mut self, event_type: EventType) -> i64 {
|
|
71
81
|
let attribs =
|
|
72
82
|
default_attribs(event_type).expect("Couldn't make default attributes in test builder");
|
|
73
|
-
self.
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/// Adds an event, returning the ID that was assigned to it
|
|
77
|
-
pub fn add_get_event_id(&mut self, event_type: EventType, attrs: Option<Attributes>) -> i64 {
|
|
78
|
-
if let Some(a) = attrs {
|
|
79
|
-
self.build_and_push_event(event_type, a);
|
|
80
|
-
} else {
|
|
81
|
-
self.add_by_type(event_type);
|
|
82
|
-
}
|
|
83
|
-
self.current_event_id
|
|
83
|
+
self.add(attribs)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/// Adds the following events:
|
|
@@ -100,25 +100,21 @@ impl TestHistoryBuilder {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
pub fn add_workflow_task_scheduled(&mut self) {
|
|
103
|
-
self.workflow_task_scheduled_event_id =
|
|
104
|
-
self.add_get_event_id(EventType::WorkflowTaskScheduled, None);
|
|
103
|
+
self.workflow_task_scheduled_event_id = self.add_by_type(EventType::WorkflowTaskScheduled);
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
pub fn add_workflow_task_started(&mut self) {
|
|
108
|
-
|
|
107
|
+
self.final_workflow_task_started_event_id = self.add(WorkflowTaskStartedEventAttributes {
|
|
109
108
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
110
109
|
..Default::default()
|
|
111
|
-
};
|
|
112
|
-
self.final_workflow_task_started_event_id =
|
|
113
|
-
self.add_get_event_id(EventType::WorkflowTaskStarted, Some(attrs.into()));
|
|
110
|
+
});
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
pub fn add_workflow_task_completed(&mut self) {
|
|
117
|
-
let
|
|
114
|
+
let id = self.add(WorkflowTaskCompletedEventAttributes {
|
|
118
115
|
scheduled_event_id: self.workflow_task_scheduled_event_id,
|
|
119
116
|
..Default::default()
|
|
120
|
-
};
|
|
121
|
-
let id = self.add_get_event_id(EventType::WorkflowTaskCompleted, Some(attrs.into()));
|
|
117
|
+
});
|
|
122
118
|
self.previous_task_completed_id = id;
|
|
123
119
|
}
|
|
124
120
|
|
|
@@ -176,30 +172,22 @@ impl TestHistoryBuilder {
|
|
|
176
172
|
}
|
|
177
173
|
|
|
178
174
|
pub fn add_activity_task_scheduled(&mut self, activity_id: impl Into<String>) -> i64 {
|
|
179
|
-
self.
|
|
180
|
-
|
|
181
|
-
Some(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
),
|
|
188
|
-
),
|
|
189
|
-
)
|
|
175
|
+
self.add(ActivityTaskScheduledEventAttributes {
|
|
176
|
+
activity_id: activity_id.into(),
|
|
177
|
+
activity_type: Some(ActivityType {
|
|
178
|
+
name: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
179
|
+
}),
|
|
180
|
+
..Default::default()
|
|
181
|
+
})
|
|
190
182
|
}
|
|
183
|
+
|
|
191
184
|
pub fn add_activity_task_started(&mut self, scheduled_event_id: i64) -> i64 {
|
|
192
|
-
self.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
..Default::default()
|
|
199
|
-
},
|
|
200
|
-
),
|
|
201
|
-
),
|
|
202
|
-
)
|
|
185
|
+
self.add(Attributes::ActivityTaskStartedEventAttributes(
|
|
186
|
+
ActivityTaskStartedEventAttributes {
|
|
187
|
+
scheduled_event_id,
|
|
188
|
+
..Default::default()
|
|
189
|
+
},
|
|
190
|
+
))
|
|
203
191
|
}
|
|
204
192
|
|
|
205
193
|
pub fn add_activity_task_completed(
|
|
@@ -208,17 +196,12 @@ impl TestHistoryBuilder {
|
|
|
208
196
|
started_event_id: i64,
|
|
209
197
|
payload: Payload,
|
|
210
198
|
) {
|
|
211
|
-
self.add(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
result: vec![payload].into_payloads(),
|
|
218
|
-
..Default::default()
|
|
219
|
-
},
|
|
220
|
-
),
|
|
221
|
-
);
|
|
199
|
+
self.add(ActivityTaskCompletedEventAttributes {
|
|
200
|
+
scheduled_event_id,
|
|
201
|
+
started_event_id,
|
|
202
|
+
result: vec![payload].into_payloads(),
|
|
203
|
+
..Default::default()
|
|
204
|
+
});
|
|
222
205
|
}
|
|
223
206
|
|
|
224
207
|
pub fn add_activity_task_cancel_requested(&mut self, scheduled_event_id: i64) {
|
|
@@ -258,13 +241,10 @@ impl TestHistoryBuilder {
|
|
|
258
241
|
}
|
|
259
242
|
|
|
260
243
|
pub fn add_timer_fired(&mut self, timer_started_evt_id: i64, timer_id: String) {
|
|
261
|
-
self.add(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
timer_id,
|
|
266
|
-
}),
|
|
267
|
-
);
|
|
244
|
+
self.add(TimerFiredEventAttributes {
|
|
245
|
+
started_event_id: timer_started_evt_id,
|
|
246
|
+
timer_id,
|
|
247
|
+
});
|
|
268
248
|
}
|
|
269
249
|
|
|
270
250
|
pub fn add_we_signaled(&mut self, signal_name: &str, payloads: Vec<Payload>) {
|
|
@@ -279,7 +259,7 @@ impl TestHistoryBuilder {
|
|
|
279
259
|
pub fn add_has_change_marker(&mut self, patch_id: &str, deprecated: bool) {
|
|
280
260
|
let attrs = MarkerRecordedEventAttributes {
|
|
281
261
|
marker_name: PATCH_MARKER_NAME.to_string(),
|
|
282
|
-
details: build_has_change_marker_details(patch_id, deprecated),
|
|
262
|
+
details: build_has_change_marker_details(patch_id, deprecated).unwrap(),
|
|
283
263
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
284
264
|
..Default::default()
|
|
285
265
|
};
|
|
@@ -292,22 +272,21 @@ impl TestHistoryBuilder {
|
|
|
292
272
|
activity_id: &str,
|
|
293
273
|
payload: Option<Payload>,
|
|
294
274
|
failure: Option<Failure>,
|
|
295
|
-
|
|
275
|
+
detail_mutator: impl FnOnce(&mut LocalActivityMarkerData),
|
|
296
276
|
) {
|
|
277
|
+
let mut lamd = LocalActivityMarkerData {
|
|
278
|
+
seq,
|
|
279
|
+
attempt: 1,
|
|
280
|
+
activity_id: activity_id.to_string(),
|
|
281
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
282
|
+
complete_time: None,
|
|
283
|
+
backoff: None,
|
|
284
|
+
original_schedule_time: None,
|
|
285
|
+
};
|
|
286
|
+
detail_mutator(&mut lamd);
|
|
297
287
|
let attrs = MarkerRecordedEventAttributes {
|
|
298
288
|
marker_name: LOCAL_ACTIVITY_MARKER_NAME.to_string(),
|
|
299
|
-
details: build_local_activity_marker_details(
|
|
300
|
-
LocalActivityMarkerData {
|
|
301
|
-
seq,
|
|
302
|
-
attempt: 1,
|
|
303
|
-
activity_id: activity_id.to_string(),
|
|
304
|
-
activity_type: "some_act_type".to_string(),
|
|
305
|
-
complete_time,
|
|
306
|
-
backoff: None,
|
|
307
|
-
original_schedule_time: None,
|
|
308
|
-
},
|
|
309
|
-
payload,
|
|
310
|
-
),
|
|
289
|
+
details: build_local_activity_marker_details(lamd, payload),
|
|
311
290
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
312
291
|
failure,
|
|
313
292
|
..Default::default()
|
|
@@ -321,7 +300,7 @@ impl TestHistoryBuilder {
|
|
|
321
300
|
activity_id: &str,
|
|
322
301
|
payload: Payload,
|
|
323
302
|
) {
|
|
324
|
-
self.add_local_activity_marker(seq, activity_id, Some(payload), None,
|
|
303
|
+
self.add_local_activity_marker(seq, activity_id, Some(payload), None, |_| {});
|
|
325
304
|
}
|
|
326
305
|
|
|
327
306
|
pub fn add_local_activity_result_marker_with_time(
|
|
@@ -331,7 +310,9 @@ impl TestHistoryBuilder {
|
|
|
331
310
|
payload: Payload,
|
|
332
311
|
complete_time: Timestamp,
|
|
333
312
|
) {
|
|
334
|
-
self.add_local_activity_marker(seq, activity_id, Some(payload), None,
|
|
313
|
+
self.add_local_activity_marker(seq, activity_id, Some(payload), None, |d| {
|
|
314
|
+
d.complete_time = Some(complete_time)
|
|
315
|
+
});
|
|
335
316
|
}
|
|
336
317
|
|
|
337
318
|
pub fn add_local_activity_fail_marker(
|
|
@@ -340,7 +321,7 @@ impl TestHistoryBuilder {
|
|
|
340
321
|
activity_id: &str,
|
|
341
322
|
failure: Failure,
|
|
342
323
|
) {
|
|
343
|
-
self.add_local_activity_marker(seq, activity_id, None, Some(failure),
|
|
324
|
+
self.add_local_activity_marker(seq, activity_id, None, Some(failure), |_| {});
|
|
344
325
|
}
|
|
345
326
|
|
|
346
327
|
pub fn add_local_activity_cancel_marker(&mut self, seq: u32, activity_id: &str) {
|
|
@@ -358,7 +339,7 @@ impl TestHistoryBuilder {
|
|
|
358
339
|
)),
|
|
359
340
|
encoded_attributes: Default::default(),
|
|
360
341
|
}),
|
|
361
|
-
|
|
342
|
+
|_| {},
|
|
362
343
|
);
|
|
363
344
|
}
|
|
364
345
|
|
|
@@ -368,7 +349,7 @@ impl TestHistoryBuilder {
|
|
|
368
349
|
workflow_id: impl Into<String>,
|
|
369
350
|
run_id: impl Into<String>,
|
|
370
351
|
) -> i64 {
|
|
371
|
-
|
|
352
|
+
self.add(SignalExternalWorkflowExecutionInitiatedEventAttributes {
|
|
372
353
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
373
354
|
workflow_execution: Some(WorkflowExecution {
|
|
374
355
|
workflow_id: workflow_id.into(),
|
|
@@ -377,11 +358,7 @@ impl TestHistoryBuilder {
|
|
|
377
358
|
signal_name: signal_name.into(),
|
|
378
359
|
control: "".to_string(),
|
|
379
360
|
..Default::default()
|
|
380
|
-
}
|
|
381
|
-
self.add_get_event_id(
|
|
382
|
-
EventType::SignalExternalWorkflowExecutionInitiated,
|
|
383
|
-
Some(attrs.into()),
|
|
384
|
-
)
|
|
361
|
+
})
|
|
385
362
|
}
|
|
386
363
|
|
|
387
364
|
pub fn add_external_signal_completed(&mut self, initiated_id: i64) {
|
|
@@ -404,18 +381,16 @@ impl TestHistoryBuilder {
|
|
|
404
381
|
}
|
|
405
382
|
|
|
406
383
|
pub fn add_cancel_external_wf(&mut self, execution: NamespacedWorkflowExecution) -> i64 {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
EventType::RequestCancelExternalWorkflowExecutionInitiated,
|
|
418
|
-
Some(attrs.into()),
|
|
384
|
+
self.add(
|
|
385
|
+
RequestCancelExternalWorkflowExecutionInitiatedEventAttributes {
|
|
386
|
+
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
387
|
+
namespace: execution.namespace,
|
|
388
|
+
workflow_execution: Some(WorkflowExecution {
|
|
389
|
+
workflow_id: execution.workflow_id,
|
|
390
|
+
run_id: execution.run_id,
|
|
391
|
+
}),
|
|
392
|
+
..Default::default()
|
|
393
|
+
},
|
|
419
394
|
)
|
|
420
395
|
}
|
|
421
396
|
|
|
@@ -441,6 +416,25 @@ impl TestHistoryBuilder {
|
|
|
441
416
|
);
|
|
442
417
|
}
|
|
443
418
|
|
|
419
|
+
pub fn add_wfe_started_with_wft_timeout(&mut self, dur: Duration) {
|
|
420
|
+
let mut wesattrs = default_wes_attribs();
|
|
421
|
+
wesattrs.workflow_task_timeout = Some(dur.try_into().unwrap());
|
|
422
|
+
self.add(wesattrs);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
pub fn add_upsert_search_attrs_for_patch(&mut self, attribs: &[String]) {
|
|
426
|
+
let mut indexed_fields = HashMap::new();
|
|
427
|
+
indexed_fields.insert(
|
|
428
|
+
"TemporalChangeVersion".to_string(),
|
|
429
|
+
attribs.as_json_payload().unwrap(),
|
|
430
|
+
);
|
|
431
|
+
let attrs = UpsertWorkflowSearchAttributesEventAttributes {
|
|
432
|
+
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
433
|
+
search_attributes: Some(SearchAttributes { indexed_fields }),
|
|
434
|
+
};
|
|
435
|
+
self.build_and_push_event(EventType::UpsertWorkflowSearchAttributes, attrs.into())
|
|
436
|
+
}
|
|
437
|
+
|
|
444
438
|
pub fn get_orig_run_id(&self) -> &str {
|
|
445
439
|
&self.original_run_id
|
|
446
440
|
}
|
|
@@ -465,7 +459,7 @@ impl TestHistoryBuilder {
|
|
|
465
459
|
}
|
|
466
460
|
|
|
467
461
|
/// Return most recent wft start time or panic if unset
|
|
468
|
-
pub fn wft_start_time(&self) ->
|
|
462
|
+
pub fn wft_start_time(&self) -> Timestamp {
|
|
469
463
|
self.events[(self.workflow_task_scheduled_event_id + 1) as usize]
|
|
470
464
|
.event_time
|
|
471
465
|
.clone()
|
|
@@ -492,6 +486,37 @@ impl TestHistoryBuilder {
|
|
|
492
486
|
modifier(he);
|
|
493
487
|
}
|
|
494
488
|
|
|
489
|
+
/// Sets internal patches which should appear in the first WFT complete event
|
|
490
|
+
pub fn set_flags_first_wft(&mut self, core: &[u32], lang: &[u32]) {
|
|
491
|
+
Self::set_flags(self.events.iter_mut(), core, lang)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/// Sets internal patches which should appear in the most recent complete event
|
|
495
|
+
pub fn set_flags_last_wft(&mut self, core: &[u32], lang: &[u32]) {
|
|
496
|
+
Self::set_flags(self.events.iter_mut().rev(), core, lang)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
fn set_flags<'a>(
|
|
500
|
+
mut events: impl Iterator<Item = &'a mut HistoryEvent>,
|
|
501
|
+
core: &[u32],
|
|
502
|
+
lang: &[u32],
|
|
503
|
+
) {
|
|
504
|
+
if let Some(first_attrs) = events.find_map(|e| {
|
|
505
|
+
if let Some(Attributes::WorkflowTaskCompletedEventAttributes(a)) = e.attributes.as_mut()
|
|
506
|
+
{
|
|
507
|
+
Some(a)
|
|
508
|
+
} else {
|
|
509
|
+
None
|
|
510
|
+
}
|
|
511
|
+
}) {
|
|
512
|
+
let sdk_dat = first_attrs
|
|
513
|
+
.sdk_metadata
|
|
514
|
+
.get_or_insert_with(Default::default);
|
|
515
|
+
sdk_dat.core_used_flags = core.to_vec();
|
|
516
|
+
sdk_dat.lang_used_flags = lang.to_vec();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
495
520
|
fn build_and_push_event(&mut self, event_type: EventType, attribs: Attributes) {
|
|
496
521
|
self.current_event_id += 1;
|
|
497
522
|
let evt = HistoryEvent {
|
|
@@ -541,3 +566,10 @@ pub fn default_wes_attribs() -> WorkflowExecutionStartedEventAttributes {
|
|
|
541
566
|
..Default::default()
|
|
542
567
|
}
|
|
543
568
|
}
|
|
569
|
+
|
|
570
|
+
pub fn default_act_sched() -> ScheduleActivity {
|
|
571
|
+
ScheduleActivity {
|
|
572
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
573
|
+
..Default::default()
|
|
574
|
+
}
|
|
575
|
+
}
|
|
@@ -136,6 +136,10 @@ impl HistoryInfo {
|
|
|
136
136
|
&self.events
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
pub fn into_events(self) -> Vec<HistoryEvent> {
|
|
140
|
+
self.events
|
|
141
|
+
}
|
|
142
|
+
|
|
139
143
|
/// Extract run id from the workflow execution started attributes.
|
|
140
144
|
pub fn orig_run_id(&self) -> &str {
|
|
141
145
|
&self.wf_exe_started_attrs.original_execution_run_id
|
|
@@ -179,6 +183,11 @@ impl HistoryInfo {
|
|
|
179
183
|
pub fn previous_started_event_id(&self) -> i64 {
|
|
180
184
|
self.previous_started_event_id
|
|
181
185
|
}
|
|
186
|
+
|
|
187
|
+
/// Returns the current workflow task started event id
|
|
188
|
+
pub fn workflow_task_started_event_id(&self) -> i64 {
|
|
189
|
+
self.workflow_task_started_event_id
|
|
190
|
+
}
|
|
182
191
|
}
|
|
183
192
|
|
|
184
193
|
impl From<HistoryInfo> for History {
|
|
@@ -204,7 +213,7 @@ mod tests {
|
|
|
204
213
|
let mut t = TestHistoryBuilder::default();
|
|
205
214
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
206
215
|
t.add_full_wf_task();
|
|
207
|
-
let timer_started_event_id = t.
|
|
216
|
+
let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
208
217
|
t.add_timer_fired(timer_started_event_id, timer_id.to_string());
|
|
209
218
|
t.add_workflow_task_scheduled_and_started();
|
|
210
219
|
t
|