@temporalio/core-bridge 1.13.0 → 1.13.2
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 +239 -382
- package/Cargo.toml +11 -11
- package/lib/native.d.ts +10 -3
- 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 +71 -11
- package/sdk-core/.clippy.toml +1 -0
- package/sdk-core/.github/workflows/heavy.yml +2 -0
- package/sdk-core/.github/workflows/per-pr.yml +50 -18
- package/sdk-core/ARCHITECTURE.md +44 -48
- package/sdk-core/Cargo.toml +26 -7
- package/sdk-core/README.md +4 -0
- package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
- package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
- package/sdk-core/arch_docs/sdks_intro.md +299 -0
- package/sdk-core/client/Cargo.toml +8 -7
- package/sdk-core/client/src/callback_based.rs +1 -2
- package/sdk-core/client/src/lib.rs +485 -299
- package/sdk-core/client/src/metrics.rs +32 -8
- package/sdk-core/client/src/proxy.rs +124 -5
- package/sdk-core/client/src/raw.rs +598 -307
- package/sdk-core/client/src/replaceable.rs +253 -0
- package/sdk-core/client/src/retry.rs +9 -6
- package/sdk-core/client/src/worker_registry/mod.rs +19 -3
- package/sdk-core/client/src/workflow_handle/mod.rs +20 -17
- package/sdk-core/core/Cargo.toml +100 -31
- package/sdk-core/core/src/core_tests/activity_tasks.rs +55 -225
- package/sdk-core/core/src/core_tests/mod.rs +2 -8
- package/sdk-core/core/src/core_tests/queries.rs +3 -5
- package/sdk-core/core/src/core_tests/replay_flag.rs +3 -62
- package/sdk-core/core/src/core_tests/updates.rs +4 -5
- package/sdk-core/core/src/core_tests/workers.rs +4 -3
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +10 -7
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +28 -291
- package/sdk-core/core/src/ephemeral_server/mod.rs +15 -3
- package/sdk-core/core/src/internal_flags.rs +11 -1
- package/sdk-core/core/src/lib.rs +50 -36
- package/sdk-core/core/src/pollers/mod.rs +5 -5
- package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
- package/sdk-core/core/src/protosext/mod.rs +13 -5
- package/sdk-core/core/src/protosext/protocol_messages.rs +4 -11
- package/sdk-core/core/src/retry_logic.rs +256 -108
- package/sdk-core/core/src/telemetry/metrics.rs +1 -0
- package/sdk-core/core/src/telemetry/mod.rs +8 -2
- package/sdk-core/core/src/telemetry/prometheus_meter.rs +2 -2
- package/sdk-core/core/src/test_help/integ_helpers.rs +971 -0
- package/sdk-core/core/src/test_help/mod.rs +10 -1100
- package/sdk-core/core/src/test_help/unit_helpers.rs +218 -0
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +42 -6
- package/sdk-core/core/src/worker/activities/local_activities.rs +19 -19
- package/sdk-core/core/src/worker/activities.rs +10 -3
- package/sdk-core/core/src/worker/client/mocks.rs +3 -3
- package/sdk-core/core/src/worker/client.rs +130 -93
- package/sdk-core/core/src/worker/heartbeat.rs +12 -13
- package/sdk-core/core/src/worker/mod.rs +31 -21
- package/sdk-core/core/src/worker/nexus.rs +14 -3
- package/sdk-core/core/src/worker/slot_provider.rs +9 -0
- package/sdk-core/core/src/worker/tuner.rs +159 -0
- package/sdk-core/core/src/worker/workflow/history_update.rs +3 -265
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -54
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -82
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -67
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -192
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -43
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +6 -554
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -71
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +102 -3
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +10 -539
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -139
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -119
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -63
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +9 -4
- package/sdk-core/core/src/worker/workflow/mod.rs +5 -1
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +8 -3
- package/sdk-core/core-api/Cargo.toml +4 -4
- package/sdk-core/core-api/src/envconfig.rs +153 -54
- package/sdk-core/core-api/src/lib.rs +68 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +2 -1
- package/sdk-core/core-api/src/telemetry.rs +13 -0
- package/sdk-core/core-c-bridge/Cargo.toml +13 -8
- package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +184 -22
- package/sdk-core/core-c-bridge/src/client.rs +462 -184
- package/sdk-core/core-c-bridge/src/envconfig.rs +314 -0
- package/sdk-core/core-c-bridge/src/lib.rs +1 -0
- package/sdk-core/core-c-bridge/src/random.rs +4 -4
- package/sdk-core/core-c-bridge/src/runtime.rs +22 -23
- package/sdk-core/core-c-bridge/src/testing.rs +1 -4
- package/sdk-core/core-c-bridge/src/tests/context.rs +31 -31
- package/sdk-core/core-c-bridge/src/tests/mod.rs +32 -28
- package/sdk-core/core-c-bridge/src/tests/utils.rs +7 -7
- package/sdk-core/core-c-bridge/src/worker.rs +319 -66
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -1
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +5 -5
- package/sdk-core/sdk/Cargo.toml +8 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/app_data.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -4
- package/sdk-core/sdk/src/lib.rs +1 -5
- package/sdk-core/sdk/src/workflow_context/options.rs +10 -1
- package/sdk-core/sdk/src/workflow_future.rs +1 -1
- package/sdk-core/sdk-core-protos/Cargo.toml +6 -6
- package/sdk-core/sdk-core-protos/build.rs +10 -23
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +9 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +254 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +234 -5
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- package/sdk-core/{test-utils → sdk-core-protos}/src/canned_histories.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -2
- package/sdk-core/sdk-core-protos/src/lib.rs +25 -9
- package/sdk-core/sdk-core-protos/src/test_utils.rs +89 -0
- package/sdk-core/sdk-core-protos/src/utilities.rs +14 -5
- package/sdk-core/tests/c_bridge_smoke_test.c +10 -0
- package/sdk-core/tests/cloud_tests.rs +10 -8
- package/sdk-core/tests/common/http_proxy.rs +134 -0
- package/sdk-core/{test-utils/src/lib.rs → tests/common/mod.rs} +214 -281
- package/sdk-core/{test-utils/src → tests/common}/workflows.rs +4 -3
- package/sdk-core/tests/fuzzy_workflow.rs +1 -1
- package/sdk-core/tests/global_metric_tests.rs +8 -7
- package/sdk-core/tests/heavy_tests.rs +7 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +111 -24
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +14 -9
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/metrics_tests.rs +114 -14
- package/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
- package/sdk-core/tests/integ_tests/polling_tests.rs +311 -93
- package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
- package/sdk-core/tests/integ_tests/update_tests.rs +13 -7
- package/sdk-core/tests/integ_tests/visibility_tests.rs +26 -9
- package/sdk-core/tests/integ_tests/worker_tests.rs +668 -13
- package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +40 -24
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +244 -11
- package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +78 -2
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +61 -2
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +465 -7
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +41 -2
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +315 -3
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1990 -14
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +65 -2
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +123 -23
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +525 -3
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +65 -16
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +32 -23
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +126 -5
- package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +1 -2
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +124 -8
- package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +62 -2
- package/sdk-core/tests/integ_tests/workflow_tests.rs +67 -8
- package/sdk-core/tests/main.rs +26 -17
- package/sdk-core/tests/manual_tests.rs +5 -1
- package/sdk-core/tests/runner.rs +22 -40
- package/sdk-core/tests/shared_tests/mod.rs +1 -1
- package/sdk-core/tests/shared_tests/priority.rs +1 -1
- package/sdk-core/{core/benches/workflow_replay.rs → tests/workflow_replay_bench.rs} +10 -5
- package/src/client.rs +97 -20
- package/src/helpers/callbacks.rs +4 -4
- package/src/helpers/errors.rs +7 -1
- package/src/helpers/handles.rs +1 -0
- package/src/helpers/try_from_js.rs +4 -3
- package/src/lib.rs +3 -2
- package/src/metrics.rs +3 -0
- package/src/runtime.rs +5 -2
- package/src/worker.rs +9 -12
- package/ts/native.ts +13 -3
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
- package/sdk-core/core/src/core_tests/determinism.rs +0 -318
- package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
- package/sdk-core/test-utils/Cargo.toml +0 -38
- package/sdk-core/test-utils/src/histfetch.rs +0 -28
- package/sdk-core/test-utils/src/interceptors.rs +0 -46
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
use crate::common::*;
|
|
2
|
+
use futures_util::StreamExt;
|
|
3
|
+
use std::sync::{
|
|
4
|
+
Arc,
|
|
5
|
+
atomic::{AtomicUsize, Ordering},
|
|
6
|
+
};
|
|
7
|
+
use temporal_client::WorkflowOptions;
|
|
8
|
+
use temporal_sdk::WfContext;
|
|
9
|
+
use temporal_sdk_core::test_help::{MockPollCfg, ResponseType, mock_worker_client};
|
|
10
|
+
use temporal_sdk_core_protos::{
|
|
11
|
+
DEFAULT_WORKFLOW_TYPE, TestHistoryBuilder,
|
|
12
|
+
temporal::api::{
|
|
13
|
+
common::v1::WorkflowExecution,
|
|
14
|
+
enums::v1::{EventType, WorkflowTaskFailedCause},
|
|
15
|
+
history::v1::{History, HistoryEvent},
|
|
16
|
+
workflowservice::v1::GetWorkflowExecutionHistoryResponse,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
#[tokio::test]
|
|
21
|
+
async fn weird_pagination_doesnt_drop_wft_events() {
|
|
22
|
+
let wf_id = "fakeid";
|
|
23
|
+
// 1: EVENT_TYPE_WORKFLOW_EXECUTION_STARTED
|
|
24
|
+
// 2: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
|
|
25
|
+
// 3: EVENT_TYPE_WORKFLOW_TASK_STARTED
|
|
26
|
+
// 4: EVENT_TYPE_WORKFLOW_TASK_COMPLETED
|
|
27
|
+
// empty page
|
|
28
|
+
// 5: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
29
|
+
// 6: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
|
|
30
|
+
// 7: EVENT_TYPE_WORKFLOW_TASK_STARTED
|
|
31
|
+
// 8: EVENT_TYPE_WORKFLOW_TASK_FAILED
|
|
32
|
+
// empty page
|
|
33
|
+
// 9: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
34
|
+
// 10: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
|
|
35
|
+
// 11: EVENT_TYPE_WORKFLOW_TASK_STARTED
|
|
36
|
+
// empty page
|
|
37
|
+
let mut t = TestHistoryBuilder::default();
|
|
38
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
39
|
+
t.add_full_wf_task();
|
|
40
|
+
|
|
41
|
+
t.add_we_signaled("hi", vec![]);
|
|
42
|
+
t.add_workflow_task_scheduled_and_started();
|
|
43
|
+
t.add_workflow_task_failed_with_failure(
|
|
44
|
+
WorkflowTaskFailedCause::UnhandledCommand,
|
|
45
|
+
Default::default(),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
t.add_we_signaled("hi", vec![]);
|
|
49
|
+
t.add_workflow_task_scheduled_and_started();
|
|
50
|
+
|
|
51
|
+
let workflow_task = t.get_full_history_info().unwrap();
|
|
52
|
+
let mut wft_resp = workflow_task.as_poll_wft_response();
|
|
53
|
+
wft_resp.workflow_execution = Some(WorkflowExecution {
|
|
54
|
+
workflow_id: wf_id.to_string(),
|
|
55
|
+
run_id: t.get_orig_run_id().to_string(),
|
|
56
|
+
});
|
|
57
|
+
// Just 9/10/11 in WFT
|
|
58
|
+
wft_resp.history.as_mut().unwrap().events.drain(0..8);
|
|
59
|
+
|
|
60
|
+
let mut resp_1: GetWorkflowExecutionHistoryResponse = t.get_full_history_info().unwrap().into();
|
|
61
|
+
resp_1.next_page_token = vec![1];
|
|
62
|
+
resp_1.history.as_mut().unwrap().events.truncate(4);
|
|
63
|
+
|
|
64
|
+
let mut mock_client = mock_worker_client();
|
|
65
|
+
mock_client
|
|
66
|
+
.expect_get_workflow_execution_history()
|
|
67
|
+
.returning(move |_, _, _| Ok(resp_1.clone()))
|
|
68
|
+
.times(1);
|
|
69
|
+
mock_client
|
|
70
|
+
.expect_get_workflow_execution_history()
|
|
71
|
+
.returning(move |_, _, _| {
|
|
72
|
+
Ok(GetWorkflowExecutionHistoryResponse {
|
|
73
|
+
history: Some(History { events: vec![] }),
|
|
74
|
+
raw_history: vec![],
|
|
75
|
+
next_page_token: vec![2],
|
|
76
|
+
archived: false,
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
.times(1);
|
|
80
|
+
let mut resp_2: GetWorkflowExecutionHistoryResponse = t.get_full_history_info().unwrap().into();
|
|
81
|
+
resp_2.next_page_token = vec![3];
|
|
82
|
+
resp_2.history.as_mut().unwrap().events.drain(0..4);
|
|
83
|
+
resp_2.history.as_mut().unwrap().events.truncate(4);
|
|
84
|
+
mock_client
|
|
85
|
+
.expect_get_workflow_execution_history()
|
|
86
|
+
.returning(move |_, _, _| Ok(resp_2.clone()))
|
|
87
|
+
.times(1);
|
|
88
|
+
mock_client
|
|
89
|
+
.expect_get_workflow_execution_history()
|
|
90
|
+
.returning(move |_, _, _| {
|
|
91
|
+
Ok(GetWorkflowExecutionHistoryResponse {
|
|
92
|
+
history: Some(History { events: vec![] }),
|
|
93
|
+
raw_history: vec![],
|
|
94
|
+
next_page_token: vec![],
|
|
95
|
+
archived: false,
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
.times(1);
|
|
99
|
+
|
|
100
|
+
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
101
|
+
let mh = MockPollCfg::from_resp_batches(wf_id, t, [ResponseType::Raw(wft_resp)], mock_client);
|
|
102
|
+
let mut worker = mock_sdk_cfg(mh, |cfg| {
|
|
103
|
+
cfg.max_cached_workflows = 2;
|
|
104
|
+
cfg.ignore_evicts_on_shutdown = false;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
let sig_ctr = Arc::new(AtomicUsize::new(0));
|
|
108
|
+
let sig_ctr_clone = sig_ctr.clone();
|
|
109
|
+
worker.register_wf(wf_type.to_owned(), move |ctx: WfContext| {
|
|
110
|
+
let sig_ctr_clone = sig_ctr_clone.clone();
|
|
111
|
+
async move {
|
|
112
|
+
let mut sigchan = ctx.make_signal_channel("hi");
|
|
113
|
+
while sigchan.next().await.is_some() {
|
|
114
|
+
if sig_ctr_clone.fetch_add(1, Ordering::AcqRel) == 1 {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
Ok(().into())
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
worker
|
|
123
|
+
.submit_wf(
|
|
124
|
+
wf_id.to_owned(),
|
|
125
|
+
wf_type.to_owned(),
|
|
126
|
+
vec![],
|
|
127
|
+
WorkflowOptions::default(),
|
|
128
|
+
)
|
|
129
|
+
.await
|
|
130
|
+
.unwrap();
|
|
131
|
+
worker.run_until_done().await.unwrap();
|
|
132
|
+
assert_eq!(sig_ctr.load(Ordering::Acquire), 2);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
#[tokio::test]
|
|
136
|
+
async fn extreme_pagination_doesnt_drop_wft_events_worker() {
|
|
137
|
+
let wf_id = "fakeid";
|
|
138
|
+
|
|
139
|
+
// In this test, we add empty pages between each event
|
|
140
|
+
|
|
141
|
+
// 1: EVENT_TYPE_WORKFLOW_EXECUTION_STARTED
|
|
142
|
+
// 2: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
|
|
143
|
+
// 3: EVENT_TYPE_WORKFLOW_TASK_STARTED // <- previous_started_event_id
|
|
144
|
+
// 4: EVENT_TYPE_WORKFLOW_TASK_COMPLETED
|
|
145
|
+
|
|
146
|
+
// 5: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
147
|
+
// 6: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
|
|
148
|
+
// 7: EVENT_TYPE_WORKFLOW_TASK_STARTED
|
|
149
|
+
// 8: EVENT_TYPE_WORKFLOW_TASK_FAILED
|
|
150
|
+
|
|
151
|
+
// 9: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
152
|
+
// 10: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
153
|
+
// 11: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
154
|
+
// 12: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
155
|
+
// 13: EVENT_TYPE_WORKFLOW_EXECUTION_SIGNALED
|
|
156
|
+
// 14: EVENT_TYPE_WORKFLOW_TASK_SCHEDULED
|
|
157
|
+
// 15: EVENT_TYPE_WORKFLOW_TASK_STARTED // <- started_event_id
|
|
158
|
+
|
|
159
|
+
let mut t = TestHistoryBuilder::default();
|
|
160
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
161
|
+
t.add_full_wf_task();
|
|
162
|
+
|
|
163
|
+
t.add_we_signaled("hi", vec![]);
|
|
164
|
+
t.add_workflow_task_scheduled_and_started();
|
|
165
|
+
t.add_workflow_task_failed_with_failure(
|
|
166
|
+
WorkflowTaskFailedCause::UnhandledCommand,
|
|
167
|
+
Default::default(),
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
t.add_we_signaled("hi", vec![]);
|
|
171
|
+
t.add_we_signaled("hi", vec![]);
|
|
172
|
+
t.add_we_signaled("hi", vec![]);
|
|
173
|
+
t.add_we_signaled("hi", vec![]);
|
|
174
|
+
t.add_we_signaled("hi", vec![]);
|
|
175
|
+
t.add_workflow_task_scheduled_and_started();
|
|
176
|
+
|
|
177
|
+
/////
|
|
178
|
+
|
|
179
|
+
let events: Vec<HistoryEvent> = t.get_full_history_info().unwrap().into_events();
|
|
180
|
+
let first_event = events[0].clone();
|
|
181
|
+
|
|
182
|
+
let mut mock_client = mock_worker_client();
|
|
183
|
+
|
|
184
|
+
for (i, event) in events.into_iter().enumerate() {
|
|
185
|
+
// Add an empty page
|
|
186
|
+
mock_client
|
|
187
|
+
.expect_get_workflow_execution_history()
|
|
188
|
+
.returning(move |_, _, _| {
|
|
189
|
+
Ok(GetWorkflowExecutionHistoryResponse {
|
|
190
|
+
history: Some(History { events: vec![] }),
|
|
191
|
+
raw_history: vec![],
|
|
192
|
+
next_page_token: vec![(i * 10 + 1) as u8],
|
|
193
|
+
archived: false,
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
.times(1);
|
|
197
|
+
|
|
198
|
+
// Add a page with just event i
|
|
199
|
+
mock_client
|
|
200
|
+
.expect_get_workflow_execution_history()
|
|
201
|
+
.returning(move |_, _, _| {
|
|
202
|
+
Ok(GetWorkflowExecutionHistoryResponse {
|
|
203
|
+
history: Some(History {
|
|
204
|
+
events: vec![event.clone()],
|
|
205
|
+
}),
|
|
206
|
+
raw_history: vec![],
|
|
207
|
+
next_page_token: vec![(i * 10) as u8],
|
|
208
|
+
archived: false,
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
.times(1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Add an extra empty page at the end, with no NPT
|
|
215
|
+
mock_client
|
|
216
|
+
.expect_get_workflow_execution_history()
|
|
217
|
+
.returning(move |_, _, _| {
|
|
218
|
+
Ok(GetWorkflowExecutionHistoryResponse {
|
|
219
|
+
history: Some(History { events: vec![] }),
|
|
220
|
+
raw_history: vec![],
|
|
221
|
+
next_page_token: vec![],
|
|
222
|
+
archived: false,
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
.times(1);
|
|
226
|
+
|
|
227
|
+
let workflow_task = t.get_full_history_info().unwrap();
|
|
228
|
+
let mut wft_resp = workflow_task.as_poll_wft_response();
|
|
229
|
+
wft_resp.workflow_execution = Some(WorkflowExecution {
|
|
230
|
+
workflow_id: wf_id.to_string(),
|
|
231
|
+
run_id: t.get_orig_run_id().to_string(),
|
|
232
|
+
});
|
|
233
|
+
wft_resp.history = Some(History {
|
|
234
|
+
events: vec![first_event],
|
|
235
|
+
});
|
|
236
|
+
wft_resp.next_page_token = vec![1];
|
|
237
|
+
wft_resp.previous_started_event_id = 3;
|
|
238
|
+
wft_resp.started_event_id = 15;
|
|
239
|
+
|
|
240
|
+
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
241
|
+
let mh = MockPollCfg::from_resp_batches(wf_id, t, [ResponseType::Raw(wft_resp)], mock_client);
|
|
242
|
+
let mut worker = mock_sdk_cfg(mh, |cfg| {
|
|
243
|
+
cfg.max_cached_workflows = 2;
|
|
244
|
+
cfg.ignore_evicts_on_shutdown = false;
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
let sig_ctr = Arc::new(AtomicUsize::new(0));
|
|
248
|
+
let sig_ctr_clone = sig_ctr.clone();
|
|
249
|
+
worker.register_wf(wf_type.to_owned(), move |ctx: WfContext| {
|
|
250
|
+
let sig_ctr_clone = sig_ctr_clone.clone();
|
|
251
|
+
async move {
|
|
252
|
+
let mut sigchan = ctx.make_signal_channel("hi");
|
|
253
|
+
while sigchan.next().await.is_some() {
|
|
254
|
+
if sig_ctr_clone.fetch_add(1, Ordering::AcqRel) == 5 {
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
Ok(().into())
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
worker
|
|
263
|
+
.submit_wf(
|
|
264
|
+
wf_id.to_owned(),
|
|
265
|
+
wf_type.to_owned(),
|
|
266
|
+
vec![],
|
|
267
|
+
WorkflowOptions::default(),
|
|
268
|
+
)
|
|
269
|
+
.await
|
|
270
|
+
.unwrap();
|
|
271
|
+
worker.run_until_done().await.unwrap();
|
|
272
|
+
assert_eq!(sig_ctr.load(Ordering::Acquire), 6);
|
|
273
|
+
}
|