@temporalio/core-bridge 1.6.0 → 1.7.1
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 +520 -456
- package/lib/index.d.ts +8 -6
- package/lib/index.js.map +1 -1
- package/package.json +8 -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/.buildkite/docker/Dockerfile +2 -2
- package/sdk-core/.buildkite/docker/docker-compose.yaml +1 -1
- package/sdk-core/.buildkite/pipeline.yml +1 -1
- package/sdk-core/.github/workflows/heavy.yml +1 -0
- package/sdk-core/README.md +13 -7
- package/sdk-core/client/src/lib.rs +27 -9
- package/sdk-core/client/src/metrics.rs +17 -8
- package/sdk-core/client/src/raw.rs +3 -3
- package/sdk-core/core/Cargo.toml +3 -4
- package/sdk-core/core/src/abstractions/take_cell.rs +28 -0
- package/sdk-core/core/src/abstractions.rs +197 -18
- package/sdk-core/core/src/core_tests/activity_tasks.rs +137 -45
- package/sdk-core/core/src/core_tests/child_workflows.rs +6 -5
- package/sdk-core/core/src/core_tests/determinism.rs +212 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +183 -36
- package/sdk-core/core/src/core_tests/queries.rs +32 -14
- package/sdk-core/core/src/core_tests/workers.rs +8 -5
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +340 -51
- package/sdk-core/core/src/ephemeral_server/mod.rs +110 -8
- package/sdk-core/core/src/internal_flags.rs +141 -0
- package/sdk-core/core/src/lib.rs +14 -9
- package/sdk-core/core/src/replay/mod.rs +16 -27
- package/sdk-core/core/src/telemetry/metrics.rs +69 -35
- package/sdk-core/core/src/telemetry/mod.rs +38 -14
- package/sdk-core/core/src/telemetry/prometheus_server.rs +19 -13
- package/sdk-core/core/src/test_help/mod.rs +65 -13
- 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 +122 -6
- package/sdk-core/core/src/worker/activities.rs +347 -173
- 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 +137 -44
- package/sdk-core/core/src/worker/workflow/history_update.rs +132 -51
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +207 -166
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +157 -82
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +12 -12
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -7
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +13 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +170 -60
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +24 -16
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +6 -8
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +320 -204
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +10 -13
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +15 -23
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +187 -46
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +237 -111
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -13
- package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +10 -6
- package/sdk-core/core/src/worker/workflow/managed_run.rs +81 -62
- package/sdk-core/core/src/worker/workflow/mod.rs +341 -79
- package/sdk-core/core/src/worker/workflow/run_cache.rs +18 -11
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +15 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +2 -0
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +75 -52
- package/sdk-core/core-api/Cargo.toml +0 -1
- package/sdk-core/core-api/src/lib.rs +13 -7
- package/sdk-core/core-api/src/telemetry.rs +4 -6
- package/sdk-core/core-api/src/worker.rs +5 -0
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +80 -55
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +22 -68
- package/sdk-core/histories/ends_empty_wft_complete.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 +1 -1
- package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +5 -17
- package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +11 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +1 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +6 -6
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +5 -0
- package/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +22 -6
- package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +48 -19
- package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -0
- package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +3 -0
- package/sdk-core/protos/api_upstream/temporal/api/{enums/v1/interaction_type.proto → protocol/v1/message.proto} +29 -11
- package/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- package/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +111 -0
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +59 -28
- package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +2 -2
- 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 +65 -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/sdk/Cargo.toml +1 -1
- package/sdk-core/sdk/src/lib.rs +21 -5
- 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 +9 -3
- package/sdk-core/sdk-core-protos/src/history_builder.rs +114 -89
- package/sdk-core/sdk-core-protos/src/history_info.rs +6 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +205 -64
- package/sdk-core/test-utils/src/canned_histories.rs +106 -296
- package/sdk-core/test-utils/src/lib.rs +32 -5
- package/sdk-core/tests/heavy_tests.rs +10 -43
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -3
- package/sdk-core/tests/integ_tests/metrics_tests.rs +218 -16
- package/sdk-core/tests/integ_tests/polling_tests.rs +3 -8
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -2
- package/sdk-core/tests/integ_tests/visibility_tests.rs +34 -23
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +97 -81
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +1 -0
- 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 +5 -1
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +25 -3
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +2 -4
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +30 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +64 -0
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +4 -0
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +3 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +7 -2
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +8 -8
- package/sdk-core/tests/main.rs +16 -25
- package/sdk-core/tests/runner.rs +11 -9
- package/src/conversions.rs +14 -8
- package/src/runtime.rs +9 -8
- package/ts/index.ts +8 -6
- package/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +0 -87
|
@@ -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, *},
|
|
@@ -19,10 +22,14 @@ use crate::{
|
|
|
19
22
|
};
|
|
20
23
|
use anyhow::bail;
|
|
21
24
|
use prost_wkt_types::Timestamp;
|
|
22
|
-
use std::
|
|
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
|
};
|
|
@@ -298,7 +278,7 @@ impl TestHistoryBuilder {
|
|
|
298
278
|
seq,
|
|
299
279
|
attempt: 1,
|
|
300
280
|
activity_id: activity_id.to_string(),
|
|
301
|
-
activity_type:
|
|
281
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
302
282
|
complete_time: None,
|
|
303
283
|
backoff: None,
|
|
304
284
|
original_schedule_time: None,
|
|
@@ -369,7 +349,7 @@ impl TestHistoryBuilder {
|
|
|
369
349
|
workflow_id: impl Into<String>,
|
|
370
350
|
run_id: impl Into<String>,
|
|
371
351
|
) -> i64 {
|
|
372
|
-
|
|
352
|
+
self.add(SignalExternalWorkflowExecutionInitiatedEventAttributes {
|
|
373
353
|
workflow_task_completed_event_id: self.previous_task_completed_id,
|
|
374
354
|
workflow_execution: Some(WorkflowExecution {
|
|
375
355
|
workflow_id: workflow_id.into(),
|
|
@@ -378,11 +358,7 @@ impl TestHistoryBuilder {
|
|
|
378
358
|
signal_name: signal_name.into(),
|
|
379
359
|
control: "".to_string(),
|
|
380
360
|
..Default::default()
|
|
381
|
-
}
|
|
382
|
-
self.add_get_event_id(
|
|
383
|
-
EventType::SignalExternalWorkflowExecutionInitiated,
|
|
384
|
-
Some(attrs.into()),
|
|
385
|
-
)
|
|
361
|
+
})
|
|
386
362
|
}
|
|
387
363
|
|
|
388
364
|
pub fn add_external_signal_completed(&mut self, initiated_id: i64) {
|
|
@@ -405,18 +381,16 @@ impl TestHistoryBuilder {
|
|
|
405
381
|
}
|
|
406
382
|
|
|
407
383
|
pub fn add_cancel_external_wf(&mut self, execution: NamespacedWorkflowExecution) -> i64 {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
EventType::RequestCancelExternalWorkflowExecutionInitiated,
|
|
419
|
-
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
|
+
},
|
|
420
394
|
)
|
|
421
395
|
}
|
|
422
396
|
|
|
@@ -445,7 +419,20 @@ impl TestHistoryBuilder {
|
|
|
445
419
|
pub fn add_wfe_started_with_wft_timeout(&mut self, dur: Duration) {
|
|
446
420
|
let mut wesattrs = default_wes_attribs();
|
|
447
421
|
wesattrs.workflow_task_timeout = Some(dur.try_into().unwrap());
|
|
448
|
-
self.add(
|
|
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())
|
|
449
436
|
}
|
|
450
437
|
|
|
451
438
|
pub fn get_orig_run_id(&self) -> &str {
|
|
@@ -499,6 +486,37 @@ impl TestHistoryBuilder {
|
|
|
499
486
|
modifier(he);
|
|
500
487
|
}
|
|
501
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
|
+
|
|
502
520
|
fn build_and_push_event(&mut self, event_type: EventType, attribs: Attributes) {
|
|
503
521
|
self.current_event_id += 1;
|
|
504
522
|
let evt = HistoryEvent {
|
|
@@ -548,3 +566,10 @@ pub fn default_wes_attribs() -> WorkflowExecutionStartedEventAttributes {
|
|
|
548
566
|
..Default::default()
|
|
549
567
|
}
|
|
550
568
|
}
|
|
569
|
+
|
|
570
|
+
pub fn default_act_sched() -> ScheduleActivity {
|
|
571
|
+
ScheduleActivity {
|
|
572
|
+
activity_type: DEFAULT_ACTIVITY_TYPE.to_string(),
|
|
573
|
+
..Default::default()
|
|
574
|
+
}
|
|
575
|
+
}
|
|
@@ -183,6 +183,11 @@ impl HistoryInfo {
|
|
|
183
183
|
pub fn previous_started_event_id(&self) -> i64 {
|
|
184
184
|
self.previous_started_event_id
|
|
185
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
|
+
}
|
|
186
191
|
}
|
|
187
192
|
|
|
188
193
|
impl From<HistoryInfo> for History {
|
|
@@ -208,7 +213,7 @@ mod tests {
|
|
|
208
213
|
let mut t = TestHistoryBuilder::default();
|
|
209
214
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
210
215
|
t.add_full_wf_task();
|
|
211
|
-
let timer_started_event_id = t.
|
|
216
|
+
let timer_started_event_id = t.add_by_type(EventType::TimerStarted);
|
|
212
217
|
t.add_timer_fired(timer_started_event_id, timer_id.to_string());
|
|
213
218
|
t.add_workflow_task_scheduled_and_started();
|
|
214
219
|
t
|