@temporalio/core-bridge 1.12.0 → 1.12.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 +64 -119
- package/Cargo.toml +1 -1
- package/index.js +3 -2
- 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 +1 -2
- package/sdk-core/.github/workflows/per-pr.yml +2 -0
- package/sdk-core/AGENTS.md +7 -0
- package/sdk-core/Cargo.toml +9 -5
- package/sdk-core/README.md +6 -5
- package/sdk-core/client/Cargo.toml +3 -2
- package/sdk-core/client/src/lib.rs +17 -8
- package/sdk-core/client/src/metrics.rs +57 -23
- package/sdk-core/client/src/raw.rs +33 -15
- package/sdk-core/core/Cargo.toml +11 -9
- package/sdk-core/core/benches/workflow_replay.rs +114 -15
- package/sdk-core/core/src/core_tests/activity_tasks.rs +18 -18
- package/sdk-core/core/src/core_tests/child_workflows.rs +4 -4
- package/sdk-core/core/src/core_tests/determinism.rs +6 -6
- package/sdk-core/core/src/core_tests/local_activities.rs +20 -20
- package/sdk-core/core/src/core_tests/mod.rs +40 -5
- package/sdk-core/core/src/core_tests/queries.rs +25 -16
- package/sdk-core/core/src/core_tests/replay_flag.rs +3 -3
- package/sdk-core/core/src/core_tests/updates.rs +3 -3
- package/sdk-core/core/src/core_tests/workers.rs +9 -7
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +40 -42
- package/sdk-core/core/src/ephemeral_server/mod.rs +1 -19
- package/sdk-core/core/src/lib.rs +10 -1
- package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
- package/sdk-core/core/src/replay/mod.rs +3 -3
- package/sdk-core/core/src/telemetry/metrics.rs +306 -152
- package/sdk-core/core/src/telemetry/mod.rs +11 -4
- package/sdk-core/core/src/telemetry/otel.rs +134 -131
- package/sdk-core/core/src/telemetry/prometheus_meter.rs +885 -0
- package/sdk-core/core/src/telemetry/prometheus_server.rs +48 -28
- package/sdk-core/core/src/test_help/mod.rs +27 -12
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -7
- package/sdk-core/core/src/worker/activities.rs +4 -4
- package/sdk-core/core/src/worker/client/mocks.rs +10 -3
- package/sdk-core/core/src/worker/client.rs +68 -5
- package/sdk-core/core/src/worker/heartbeat.rs +229 -0
- package/sdk-core/core/src/worker/mod.rs +35 -14
- package/sdk-core/core/src/worker/tuner/resource_based.rs +4 -4
- package/sdk-core/core/src/worker/workflow/history_update.rs +71 -19
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -2
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -1
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +31 -48
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -2
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +3 -3
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +4 -1
- package/sdk-core/core/src/worker/workflow/managed_run.rs +1 -1
- package/sdk-core/core/src/worker/workflow/mod.rs +15 -15
- package/sdk-core/core-api/Cargo.toml +2 -2
- package/sdk-core/core-api/src/envconfig.rs +204 -99
- package/sdk-core/core-api/src/lib.rs +9 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +548 -100
- package/sdk-core/core-api/src/worker.rs +11 -5
- package/sdk-core/core-c-bridge/Cargo.toml +49 -0
- package/sdk-core/core-c-bridge/build.rs +26 -0
- package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +817 -0
- package/sdk-core/core-c-bridge/src/client.rs +679 -0
- package/sdk-core/core-c-bridge/src/lib.rs +245 -0
- package/sdk-core/core-c-bridge/src/metric.rs +682 -0
- package/sdk-core/core-c-bridge/src/random.rs +61 -0
- package/sdk-core/core-c-bridge/src/runtime.rs +445 -0
- package/sdk-core/core-c-bridge/src/testing.rs +282 -0
- package/sdk-core/core-c-bridge/src/tests/context.rs +644 -0
- package/sdk-core/core-c-bridge/src/tests/mod.rs +178 -0
- package/sdk-core/core-c-bridge/src/tests/utils.rs +108 -0
- package/sdk-core/core-c-bridge/src/worker.rs +1069 -0
- package/sdk-core/etc/deps.svg +64 -64
- package/sdk-core/sdk/src/activity_context.rs +6 -4
- package/sdk-core/sdk/src/lib.rs +49 -27
- package/sdk-core/sdk/src/workflow_future.rs +18 -25
- package/sdk-core/sdk-core-protos/protos/api_upstream/README.md +4 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +0 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +630 -83
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +632 -78
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +4 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +32 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +10 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +26 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +4 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +47 -31
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +4 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +7 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/worker/v1/message.proto +134 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +14 -11
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +148 -37
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +21 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -4
- package/sdk-core/sdk-core-protos/src/history_builder.rs +9 -5
- package/sdk-core/sdk-core-protos/src/lib.rs +96 -6
- package/sdk-core/test-utils/src/lib.rs +11 -3
- package/sdk-core/tests/cloud_tests.rs +3 -3
- package/sdk-core/tests/heavy_tests.rs +11 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +12 -13
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/metrics_tests.rs +188 -83
- package/sdk-core/tests/integ_tests/polling_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/queries_tests.rs +56 -40
- package/sdk-core/tests/integ_tests/update_tests.rs +2 -7
- package/sdk-core/tests/integ_tests/worker_tests.rs +3 -4
- package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +3 -7
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +3 -5
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +24 -17
- package/src/client.rs +6 -0
- package/src/metrics.rs +6 -6
|
@@ -13,7 +13,7 @@ use crate::{
|
|
|
13
13
|
},
|
|
14
14
|
worker::{
|
|
15
15
|
TunerBuilder,
|
|
16
|
-
client::mocks::{
|
|
16
|
+
client::mocks::{mock_manual_worker_client, mock_worker_client},
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
use futures_util::{FutureExt, stream};
|
|
@@ -499,7 +499,7 @@ async fn abandoned_activities_ignore_start_and_complete(hist_batches: &'static [
|
|
|
499
499
|
t.add_timer_fired(timer_started_event_id, "2".to_string());
|
|
500
500
|
t.add_full_wf_task();
|
|
501
501
|
t.add_workflow_execution_completed();
|
|
502
|
-
let mock =
|
|
502
|
+
let mock = mock_worker_client();
|
|
503
503
|
let mut worker = mock_sdk(MockPollCfg::from_resp_batches(wfid, t, hist_batches, mock));
|
|
504
504
|
|
|
505
505
|
worker.register_wf(wf_type.to_owned(), |ctx: WfContext| async move {
|
|
@@ -1156,7 +1156,7 @@ async fn wft_timeout_repro(hist_batches: &'static [usize]) {
|
|
|
1156
1156
|
async fn complete_after_eviction() {
|
|
1157
1157
|
let wfid = "fake_wf_id";
|
|
1158
1158
|
let t = canned_histories::single_timer("1");
|
|
1159
|
-
let mut mock =
|
|
1159
|
+
let mut mock = mock_worker_client();
|
|
1160
1160
|
mock.expect_complete_workflow_task().times(0);
|
|
1161
1161
|
let mock = single_hist_mock_sg(wfid, t, [2], mock, true);
|
|
1162
1162
|
let core = mock_worker(mock);
|
|
@@ -1194,7 +1194,7 @@ async fn sends_appropriate_sticky_task_queue_responses() {
|
|
|
1194
1194
|
// include the information that tells the server to enqueue the next task on a sticky queue.
|
|
1195
1195
|
let wfid = "fake_wf_id";
|
|
1196
1196
|
let t = canned_histories::single_timer("1");
|
|
1197
|
-
let mut mock =
|
|
1197
|
+
let mut mock = mock_worker_client();
|
|
1198
1198
|
mock.expect_complete_workflow_task()
|
|
1199
1199
|
.withf(|comp| comp.sticky_attributes.is_some())
|
|
1200
1200
|
.times(1)
|
|
@@ -1218,7 +1218,7 @@ async fn sends_appropriate_sticky_task_queue_responses() {
|
|
|
1218
1218
|
async fn new_server_work_while_eviction_outstanding_doesnt_overwrite_activation() {
|
|
1219
1219
|
let wfid = "fake_wf_id";
|
|
1220
1220
|
let t = canned_histories::single_timer("1");
|
|
1221
|
-
let mock = single_hist_mock_sg(wfid, t, [1, 2],
|
|
1221
|
+
let mock = single_hist_mock_sg(wfid, t, [1, 2], mock_worker_client(), false);
|
|
1222
1222
|
let taskmap = mock.outstanding_task_map.clone().unwrap();
|
|
1223
1223
|
let core = mock_worker(mock);
|
|
1224
1224
|
|
|
@@ -1279,7 +1279,7 @@ async fn buffered_work_drained_on_shutdown() {
|
|
|
1279
1279
|
tasks.extend(
|
|
1280
1280
|
std::iter::repeat_with(|| hist_to_poll_resp(&t, wfid.to_owned(), 2.into()).resp).take(50),
|
|
1281
1281
|
);
|
|
1282
|
-
let mut mock =
|
|
1282
|
+
let mut mock = mock_worker_client();
|
|
1283
1283
|
mock.expect_complete_workflow_task()
|
|
1284
1284
|
.returning(|_| Ok(RespondWorkflowTaskCompletedResponse::default()));
|
|
1285
1285
|
let mut mock = MocksHolder::from_wft_stream(mock, stream::iter(tasks));
|
|
@@ -1323,7 +1323,7 @@ async fn fail_wft_then_recover() {
|
|
|
1323
1323
|
t,
|
|
1324
1324
|
// We need to deliver all of history twice because of eviction
|
|
1325
1325
|
[ResponseType::AllHistory, ResponseType::AllHistory],
|
|
1326
|
-
|
|
1326
|
+
mock_worker_client(),
|
|
1327
1327
|
);
|
|
1328
1328
|
mh.num_expected_fails = 1;
|
|
1329
1329
|
mh.expect_fail_wft_matcher =
|
|
@@ -1388,7 +1388,7 @@ async fn poll_response_triggers_wf_error() {
|
|
|
1388
1388
|
"fake_wf_id",
|
|
1389
1389
|
t,
|
|
1390
1390
|
[ResponseType::AllHistory],
|
|
1391
|
-
|
|
1391
|
+
mock_worker_client(),
|
|
1392
1392
|
);
|
|
1393
1393
|
// Fail wft will be called when auto-failing.
|
|
1394
1394
|
mh.num_expected_fails = 1;
|
|
@@ -1418,7 +1418,7 @@ async fn lang_slower_than_wft_timeouts() {
|
|
|
1418
1418
|
t.add_full_wf_task();
|
|
1419
1419
|
t.add_workflow_execution_completed();
|
|
1420
1420
|
|
|
1421
|
-
let mut mock =
|
|
1421
|
+
let mut mock = mock_worker_client();
|
|
1422
1422
|
mock.expect_complete_workflow_task()
|
|
1423
1423
|
.times(1)
|
|
1424
1424
|
.returning(|_| Err(tonic::Status::not_found("Workflow task not found.")));
|
|
@@ -1476,7 +1476,7 @@ async fn tries_cancel_of_completed_activity() {
|
|
|
1476
1476
|
t.add_activity_task_completed(scheduled_event_id, started_event_id, Default::default());
|
|
1477
1477
|
t.add_workflow_task_scheduled_and_started();
|
|
1478
1478
|
|
|
1479
|
-
let mock =
|
|
1479
|
+
let mock = mock_worker_client();
|
|
1480
1480
|
let mut mock = single_hist_mock_sg("fake_wf_id", t, [1, 2], mock, true);
|
|
1481
1481
|
mock.worker_cfg(|cfg| cfg.max_cached_workflows = 1);
|
|
1482
1482
|
let core = mock_worker(mock);
|
|
@@ -1524,7 +1524,7 @@ async fn failing_wft_doesnt_eat_permit_forever() {
|
|
|
1524
1524
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
1525
1525
|
t.add_workflow_task_scheduled_and_started();
|
|
1526
1526
|
|
|
1527
|
-
let mock =
|
|
1527
|
+
let mock = mock_worker_client();
|
|
1528
1528
|
let mut mock = MockPollCfg::from_resp_batches("fake_wf_id", t, [1, 1, 1], mock);
|
|
1529
1529
|
mock.num_expected_fails = 1;
|
|
1530
1530
|
let mut mock = build_mock_pollers(mock);
|
|
@@ -1586,7 +1586,7 @@ async fn cache_miss_will_fetch_history() {
|
|
|
1586
1586
|
"fake_wf_id",
|
|
1587
1587
|
t,
|
|
1588
1588
|
[ResponseType::ToTaskNum(1), ResponseType::OneTask(2)],
|
|
1589
|
-
|
|
1589
|
+
mock_worker_client(),
|
|
1590
1590
|
);
|
|
1591
1591
|
mh.mock_client
|
|
1592
1592
|
.expect_get_workflow_execution_history()
|
|
@@ -1682,7 +1682,7 @@ async fn history_byte_size_and_can_suggestion_in_activation() {
|
|
|
1682
1682
|
"fake_wf_id",
|
|
1683
1683
|
t,
|
|
1684
1684
|
[ResponseType::ToTaskNum(1), ResponseType::OneTask(2)],
|
|
1685
|
-
|
|
1685
|
+
mock_worker_client(),
|
|
1686
1686
|
);
|
|
1687
1687
|
let mut mock = build_mock_pollers(mh);
|
|
1688
1688
|
mock.worker_cfg(|cfg| cfg.max_cached_workflows = 1);
|
|
@@ -1713,7 +1713,7 @@ async fn tasks_from_completion_are_delivered() {
|
|
|
1713
1713
|
t.add_full_wf_task();
|
|
1714
1714
|
t.add_workflow_execution_completed();
|
|
1715
1715
|
|
|
1716
|
-
let mut mock =
|
|
1716
|
+
let mut mock = mock_worker_client();
|
|
1717
1717
|
let complete_resp = RespondWorkflowTaskCompletedResponse {
|
|
1718
1718
|
workflow_task: Some(hist_to_poll_resp(&t, wfid.to_owned(), 2.into()).resp),
|
|
1719
1719
|
activity_tasks: vec![],
|
|
@@ -1758,7 +1758,7 @@ async fn pagination_works_with_tasks_from_completion() {
|
|
|
1758
1758
|
t.add_we_signaled("sig", vec![]);
|
|
1759
1759
|
t.add_workflow_task_scheduled_and_started();
|
|
1760
1760
|
|
|
1761
|
-
let mut mock =
|
|
1761
|
+
let mut mock = mock_worker_client();
|
|
1762
1762
|
let mut needs_pag_resp = hist_to_poll_resp(&t, wfid.to_owned(), ResponseType::OneTask(2)).resp;
|
|
1763
1763
|
needs_pag_resp.next_page_token = vec![1];
|
|
1764
1764
|
let complete_resp = RespondWorkflowTaskCompletedResponse {
|
|
@@ -1812,7 +1812,7 @@ async fn poll_faster_than_complete_wont_overflow_cache() {
|
|
|
1812
1812
|
response_batches: vec![ResponseType::ToTaskNum(1)],
|
|
1813
1813
|
})
|
|
1814
1814
|
.collect();
|
|
1815
|
-
let mut mock_client =
|
|
1815
|
+
let mut mock_client = mock_worker_client();
|
|
1816
1816
|
mock_client
|
|
1817
1817
|
.expect_complete_workflow_task()
|
|
1818
1818
|
.times(3)
|
|
@@ -1937,7 +1937,7 @@ async fn poll_faster_than_complete_wont_overflow_cache() {
|
|
|
1937
1937
|
async fn eviction_waits_until_replay_finished() {
|
|
1938
1938
|
let wfid = "fake_wf_id";
|
|
1939
1939
|
let t = canned_histories::long_sequential_timers(3);
|
|
1940
|
-
let mock =
|
|
1940
|
+
let mock = mock_worker_client();
|
|
1941
1941
|
let mock = single_hist_mock_sg(wfid, t, [3], mock, true);
|
|
1942
1942
|
let core = mock_worker(mock);
|
|
1943
1943
|
|
|
@@ -1998,7 +1998,7 @@ async fn autocompletes_wft_no_work() {
|
|
|
1998
1998
|
let started_event_id = t.add_activity_task_started(scheduled_event_id);
|
|
1999
1999
|
t.add_activity_task_completed(scheduled_event_id, started_event_id, Default::default());
|
|
2000
2000
|
t.add_full_wf_task();
|
|
2001
|
-
let mock =
|
|
2001
|
+
let mock = mock_worker_client();
|
|
2002
2002
|
let mut mock = single_hist_mock_sg(wfid, t, [1, 2, 3, 4], mock, true);
|
|
2003
2003
|
mock.worker_cfg(|w| w.max_cached_workflows = 1);
|
|
2004
2004
|
let core = mock_worker(mock);
|
|
@@ -2052,7 +2052,7 @@ async fn autocompletes_wft_no_work() {
|
|
|
2052
2052
|
#[tokio::test]
|
|
2053
2053
|
async fn no_race_acquiring_permits() {
|
|
2054
2054
|
let wfid = "fake_wf_id";
|
|
2055
|
-
let mut mock_client =
|
|
2055
|
+
let mut mock_client = mock_manual_worker_client();
|
|
2056
2056
|
// We need to allow two polls to happen by triggering two processing events in the workflow
|
|
2057
2057
|
// stream, but then delivering the actual tasks after that
|
|
2058
2058
|
let task_barr: &'static Barrier = Box::leak(Box::new(Barrier::new(2)));
|
|
@@ -2127,7 +2127,7 @@ async fn continue_as_new_preserves_some_values() {
|
|
|
2127
2127
|
wes_attrs.memo = Some(memo);
|
|
2128
2128
|
wes_attrs.search_attributes = Some(search);
|
|
2129
2129
|
wes_attrs.retry_policy = Some(retry_policy);
|
|
2130
|
-
let mut mock_client =
|
|
2130
|
+
let mut mock_client = mock_worker_client();
|
|
2131
2131
|
let t = {
|
|
2132
2132
|
let mut t = TestHistoryBuilder::default();
|
|
2133
2133
|
t.add(wes_attrs.clone());
|
|
@@ -2185,7 +2185,7 @@ async fn ignorable_events_are_ok(#[values(true, false)] attribs_unset: bool) {
|
|
|
2185
2185
|
});
|
|
2186
2186
|
t.add_workflow_task_scheduled_and_started();
|
|
2187
2187
|
|
|
2188
|
-
let mock =
|
|
2188
|
+
let mock = mock_worker_client();
|
|
2189
2189
|
let mock = single_hist_mock_sg("wheee", t, [ResponseType::AllHistory], mock, true);
|
|
2190
2190
|
let core = mock_worker(mock);
|
|
2191
2191
|
|
|
@@ -2198,7 +2198,7 @@ async fn ignorable_events_are_ok(#[values(true, false)] attribs_unset: bool) {
|
|
|
2198
2198
|
|
|
2199
2199
|
#[tokio::test]
|
|
2200
2200
|
async fn fetching_to_continue_replay_works() {
|
|
2201
|
-
let mut mock_client =
|
|
2201
|
+
let mut mock_client = mock_worker_client();
|
|
2202
2202
|
let mut t = TestHistoryBuilder::default();
|
|
2203
2203
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
2204
2204
|
t.add_full_wf_task();
|
|
@@ -2269,7 +2269,7 @@ async fn fetching_to_continue_replay_works() {
|
|
|
2269
2269
|
|
|
2270
2270
|
#[tokio::test]
|
|
2271
2271
|
async fn fetching_error_evicts_wf() {
|
|
2272
|
-
let mut mock_client =
|
|
2272
|
+
let mut mock_client = mock_worker_client();
|
|
2273
2273
|
let mut t = TestHistoryBuilder::default();
|
|
2274
2274
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
2275
2275
|
t.add_workflow_task_scheduled_and_started();
|
|
@@ -2336,7 +2336,7 @@ async fn ensure_fetching_fail_during_complete_sends_task_failure() {
|
|
|
2336
2336
|
next_page.history.as_mut().unwrap().events.truncate(9);
|
|
2337
2337
|
next_page.next_page_token = vec![2];
|
|
2338
2338
|
|
|
2339
|
-
let mut mock =
|
|
2339
|
+
let mut mock = mock_worker_client();
|
|
2340
2340
|
mock.expect_get_workflow_execution_history()
|
|
2341
2341
|
.returning(move |_, _, _| {
|
|
2342
2342
|
error!("Called fetch!");
|
|
@@ -2392,7 +2392,7 @@ async fn lang_internal_flags() {
|
|
|
2392
2392
|
"fake_wf_id",
|
|
2393
2393
|
t,
|
|
2394
2394
|
[ResponseType::ToTaskNum(2), ResponseType::AllHistory],
|
|
2395
|
-
|
|
2395
|
+
mock_worker_client(),
|
|
2396
2396
|
);
|
|
2397
2397
|
mh.completion_mock_fn = Some(Box::new(|c| {
|
|
2398
2398
|
assert_matches!(c.sdk_metadata.lang_used_flags.as_slice(), &[2]);
|
|
@@ -2433,7 +2433,7 @@ async fn lang_internal_flag_with_update() {
|
|
|
2433
2433
|
"fake_wf_id",
|
|
2434
2434
|
t,
|
|
2435
2435
|
[ResponseType::AllHistory],
|
|
2436
|
-
|
|
2436
|
+
mock_worker_client(),
|
|
2437
2437
|
);
|
|
2438
2438
|
let mut mock = build_mock_pollers(mh);
|
|
2439
2439
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 1);
|
|
@@ -2483,7 +2483,7 @@ async fn core_internal_flags() {
|
|
|
2483
2483
|
"fake_wf_id",
|
|
2484
2484
|
t,
|
|
2485
2485
|
[ResponseType::ToTaskNum(1)],
|
|
2486
|
-
|
|
2486
|
+
mock_worker_client(),
|
|
2487
2487
|
);
|
|
2488
2488
|
mh.completion_mock_fn = Some(Box::new(move |c| {
|
|
2489
2489
|
assert_eq!(
|
|
@@ -2528,7 +2528,7 @@ async fn post_terminal_commands_are_retained_when_not_replaying() {
|
|
|
2528
2528
|
]);
|
|
2529
2529
|
_do_post_terminal_commands_test(
|
|
2530
2530
|
commands_sent_by_lang,
|
|
2531
|
-
[ResponseType::ToTaskNum(1)
|
|
2531
|
+
[ResponseType::ToTaskNum(1)],
|
|
2532
2532
|
expected_command_types_emitted,
|
|
2533
2533
|
t,
|
|
2534
2534
|
)
|
|
@@ -2585,7 +2585,7 @@ async fn _do_post_terminal_commands_test(
|
|
|
2585
2585
|
t: TestHistoryBuilder,
|
|
2586
2586
|
) {
|
|
2587
2587
|
let mut mh =
|
|
2588
|
-
MockPollCfg::from_resp_batches("fake_wf_id", t, response_types,
|
|
2588
|
+
MockPollCfg::from_resp_batches("fake_wf_id", t, response_types, mock_worker_client());
|
|
2589
2589
|
if let Some(expected_command_types) = expected_command_types {
|
|
2590
2590
|
mh.num_expected_completions = Some(TimesRange::from(1));
|
|
2591
2591
|
mh.completion_mock_fn = Some(Box::new(move |c| {
|
|
@@ -2602,7 +2602,6 @@ async fn _do_post_terminal_commands_test(
|
|
|
2602
2602
|
|
|
2603
2603
|
let act = core.poll_workflow_activation().await.unwrap();
|
|
2604
2604
|
|
|
2605
|
-
core.initiate_shutdown();
|
|
2606
2605
|
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
2607
2606
|
act.run_id,
|
|
2608
2607
|
commands_sent_by_lang,
|
|
@@ -2610,6 +2609,7 @@ async fn _do_post_terminal_commands_test(
|
|
|
2610
2609
|
.await
|
|
2611
2610
|
.unwrap();
|
|
2612
2611
|
|
|
2612
|
+
core.initiate_shutdown();
|
|
2613
2613
|
let act = core.poll_workflow_activation().await;
|
|
2614
2614
|
assert_matches!(act.unwrap_err(), PollError::ShutDown);
|
|
2615
2615
|
core.shutdown().await;
|
|
@@ -2636,7 +2636,7 @@ async fn jobs_are_in_appropriate_order() {
|
|
|
2636
2636
|
"fake_wf_id",
|
|
2637
2637
|
t,
|
|
2638
2638
|
[ResponseType::AllHistory],
|
|
2639
|
-
|
|
2639
|
+
mock_worker_client(),
|
|
2640
2640
|
);
|
|
2641
2641
|
let mut mock = build_mock_pollers(mh);
|
|
2642
2642
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 1);
|
|
@@ -2685,10 +2685,6 @@ async fn history_length_with_fail_and_timeout(
|
|
|
2685
2685
|
#[values(true, false)] use_cache: bool,
|
|
2686
2686
|
#[values(1, 2, 3)] history_responses_case: u8,
|
|
2687
2687
|
) {
|
|
2688
|
-
if !use_cache && history_responses_case == 3 {
|
|
2689
|
-
/* disabled for now because this keeps flaking*/
|
|
2690
|
-
return;
|
|
2691
|
-
}
|
|
2692
2688
|
let wfid = "fake_wf_id";
|
|
2693
2689
|
let mut t = TestHistoryBuilder::default();
|
|
2694
2690
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
@@ -2705,7 +2701,7 @@ async fn history_length_with_fail_and_timeout(
|
|
|
2705
2701
|
t.add_full_wf_task();
|
|
2706
2702
|
t.add_workflow_execution_completed();
|
|
2707
2703
|
|
|
2708
|
-
let mut mock_client =
|
|
2704
|
+
let mut mock_client = mock_worker_client();
|
|
2709
2705
|
let history_responses = match history_responses_case {
|
|
2710
2706
|
1 => vec![ResponseType::AllHistory],
|
|
2711
2707
|
2 => vec![
|
|
@@ -2779,7 +2775,7 @@ async fn poller_wont_run_ahead_of_task_slots() {
|
|
|
2779
2775
|
)
|
|
2780
2776
|
.resp
|
|
2781
2777
|
});
|
|
2782
|
-
let mut mock_client =
|
|
2778
|
+
let mut mock_client = mock_worker_client();
|
|
2783
2779
|
mock_client
|
|
2784
2780
|
.expect_poll_workflow_task()
|
|
2785
2781
|
.returning(move |_, _| Ok(bunch_of_first_tasks.next().unwrap()));
|
|
@@ -2837,7 +2833,7 @@ async fn poller_wont_run_ahead_of_task_slots() {
|
|
|
2837
2833
|
|
|
2838
2834
|
#[tokio::test]
|
|
2839
2835
|
async fn poller_wont_poll_until_lang_polls() {
|
|
2840
|
-
let mut mock_client =
|
|
2836
|
+
let mut mock_client = mock_worker_client();
|
|
2841
2837
|
let (tx, rx) = sync_channel(101);
|
|
2842
2838
|
// Normally you'd just not set any expectations, but the problem is since we never poll
|
|
2843
2839
|
// the WFT stream, we'll never join the tasks running the pollers and thus the error
|
|
@@ -2878,7 +2874,7 @@ async fn use_compatible_version_flag(
|
|
|
2878
2874
|
#[values("activity", "child_wf", "continue_as_new")] command_type: &'static str,
|
|
2879
2875
|
) {
|
|
2880
2876
|
let wfid = "fake_wf_id";
|
|
2881
|
-
let mut mock_client =
|
|
2877
|
+
let mut mock_client = mock_worker_client();
|
|
2882
2878
|
let t = {
|
|
2883
2879
|
let mut t = TestHistoryBuilder::default();
|
|
2884
2880
|
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
@@ -2890,6 +2886,7 @@ async fn use_compatible_version_flag(
|
|
|
2890
2886
|
VersioningIntent::Compatible => true,
|
|
2891
2887
|
VersioningIntent::Default => false,
|
|
2892
2888
|
};
|
|
2889
|
+
#[allow(deprecated)]
|
|
2893
2890
|
mock_client
|
|
2894
2891
|
.expect_complete_workflow_task()
|
|
2895
2892
|
.returning(move |mut c| {
|
|
@@ -2974,7 +2971,7 @@ async fn sets_build_id_from_wft_complete() {
|
|
|
2974
2971
|
t.add_timer_fired(timer_started_event_id, "2".to_string());
|
|
2975
2972
|
t.add_workflow_task_scheduled_and_started();
|
|
2976
2973
|
|
|
2977
|
-
let mock =
|
|
2974
|
+
let mock = mock_worker_client();
|
|
2978
2975
|
let mut worker = mock_sdk_cfg(
|
|
2979
2976
|
MockPollCfg::from_resp_batches(wfid, t, [ResponseType::AllHistory], mock),
|
|
2980
2977
|
|cfg| {
|
|
@@ -3026,7 +3023,7 @@ async fn slot_provider_cant_hand_out_more_permits_than_cache_size() {
|
|
|
3026
3023
|
)
|
|
3027
3024
|
.resp
|
|
3028
3025
|
});
|
|
3029
|
-
let mut mock_client =
|
|
3026
|
+
let mut mock_client = mock_worker_client();
|
|
3030
3027
|
mock_client
|
|
3031
3028
|
.expect_poll_workflow_task()
|
|
3032
3029
|
.returning(move |_, _| Ok(bunch_of_first_tasks.next().unwrap()));
|
|
@@ -3189,7 +3186,7 @@ async fn both_normal_and_sticky_pollers_poll_concurrently() {
|
|
|
3189
3186
|
.resp
|
|
3190
3187
|
});
|
|
3191
3188
|
|
|
3192
|
-
let mut mock_client =
|
|
3189
|
+
let mut mock_client = mock_worker_client();
|
|
3193
3190
|
|
|
3194
3191
|
// Track normal vs sticky poll requests and return actual workflow tasks
|
|
3195
3192
|
let cc = Arc::clone(&counters);
|
|
@@ -3261,6 +3258,7 @@ async fn both_normal_and_sticky_pollers_poll_concurrently() {
|
|
|
3261
3258
|
Some("stickytq".to_string()),
|
|
3262
3259
|
Arc::new(mock_client),
|
|
3263
3260
|
None,
|
|
3261
|
+
None,
|
|
3264
3262
|
);
|
|
3265
3263
|
|
|
3266
3264
|
for _ in 1..50 {
|
|
@@ -423,7 +423,7 @@ fn get_free_port(bind_ip: &str) -> io::Result<u16> {
|
|
|
423
423
|
let addr = listen.local_addr()?;
|
|
424
424
|
|
|
425
425
|
// On Linux and some BSD variants, ephemeral ports are randomized, and may
|
|
426
|
-
// consequently repeat within a short time frame after the
|
|
426
|
+
// consequently repeat within a short time frame after the listening end
|
|
427
427
|
// has been closed. To avoid this, we make a connection to the port, then
|
|
428
428
|
// close that connection from the server's side (this is very important),
|
|
429
429
|
// which puts the connection in TIME_WAIT state for some time (by default,
|
|
@@ -622,30 +622,12 @@ fn remove_file_past_ttl(ttl: &Option<Duration>, dest: &PathBuf) -> Result<bool,
|
|
|
622
622
|
mod tests {
|
|
623
623
|
use super::{get_free_port, remove_file_past_ttl};
|
|
624
624
|
use std::{
|
|
625
|
-
collections::HashSet,
|
|
626
625
|
env::temp_dir,
|
|
627
626
|
fs::File,
|
|
628
627
|
net::{TcpListener, TcpStream},
|
|
629
628
|
time::{Duration, SystemTime},
|
|
630
629
|
};
|
|
631
630
|
|
|
632
|
-
#[test]
|
|
633
|
-
fn get_free_port_no_double() {
|
|
634
|
-
let host = "127.0.0.1";
|
|
635
|
-
let mut port_set = HashSet::new();
|
|
636
|
-
|
|
637
|
-
for _ in 0..2000 {
|
|
638
|
-
let port = get_free_port(host).unwrap();
|
|
639
|
-
assert!(
|
|
640
|
-
!port_set.contains(&port),
|
|
641
|
-
"Port {port} has been assigned more than once"
|
|
642
|
-
);
|
|
643
|
-
|
|
644
|
-
// Add port to the set
|
|
645
|
-
port_set.insert(port);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
631
|
#[test]
|
|
650
632
|
fn get_free_port_can_bind_immediately() {
|
|
651
633
|
let host = "127.0.0.1";
|
package/sdk-core/core/src/lib.rs
CHANGED
|
@@ -61,7 +61,7 @@ use crate::{
|
|
|
61
61
|
};
|
|
62
62
|
use anyhow::bail;
|
|
63
63
|
use futures_util::Stream;
|
|
64
|
-
use std::sync::Arc;
|
|
64
|
+
use std::sync::{Arc, OnceLock};
|
|
65
65
|
use temporal_client::{ConfiguredClient, NamespacedClient, TemporalServiceClientWithMetrics};
|
|
66
66
|
use temporal_sdk_core_api::{
|
|
67
67
|
Worker as WorkerTrait,
|
|
@@ -98,11 +98,19 @@ where
|
|
|
98
98
|
}
|
|
99
99
|
let client_ident = client.get_identity().to_owned();
|
|
100
100
|
let sticky_q = sticky_q_name_for_worker(&client_ident, &worker_config);
|
|
101
|
+
|
|
102
|
+
if client_ident.is_empty() {
|
|
103
|
+
bail!("Client identity cannot be empty. Either lang or user should be setting this value");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let heartbeat_fn = Arc::new(OnceLock::new());
|
|
107
|
+
|
|
101
108
|
let client_bag = Arc::new(WorkerClientBag::new(
|
|
102
109
|
client,
|
|
103
110
|
worker_config.namespace.clone(),
|
|
104
111
|
client_ident,
|
|
105
112
|
worker_config.versioning_strategy.clone(),
|
|
113
|
+
heartbeat_fn.clone(),
|
|
106
114
|
));
|
|
107
115
|
|
|
108
116
|
Ok(Worker::new(
|
|
@@ -110,6 +118,7 @@ where
|
|
|
110
118
|
sticky_q,
|
|
111
119
|
client_bag,
|
|
112
120
|
Some(&runtime.telemetry),
|
|
121
|
+
Some(heartbeat_fn),
|
|
113
122
|
))
|
|
114
123
|
}
|
|
115
124
|
|
|
@@ -697,7 +697,7 @@ mod tests {
|
|
|
697
697
|
use super::*;
|
|
698
698
|
use crate::{
|
|
699
699
|
abstractions::tests::fixed_size_permit_dealer,
|
|
700
|
-
worker::client::mocks::
|
|
700
|
+
worker::client::mocks::mock_manual_worker_client,
|
|
701
701
|
};
|
|
702
702
|
use futures_util::FutureExt;
|
|
703
703
|
use std::time::Duration;
|
|
@@ -705,7 +705,7 @@ mod tests {
|
|
|
705
705
|
|
|
706
706
|
#[tokio::test]
|
|
707
707
|
async fn only_polls_once_with_1_poller() {
|
|
708
|
-
let mut mock_client =
|
|
708
|
+
let mut mock_client = mock_manual_worker_client();
|
|
709
709
|
mock_client
|
|
710
710
|
.expect_poll_workflow_task()
|
|
711
711
|
.times(2)
|
|
@@ -6,7 +6,7 @@ use crate::{
|
|
|
6
6
|
Worker,
|
|
7
7
|
worker::{
|
|
8
8
|
PostActivateHookData,
|
|
9
|
-
client::mocks::{MockManualWorkerClient,
|
|
9
|
+
client::mocks::{MockManualWorkerClient, mock_manual_worker_client},
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
12
|
use futures_util::{FutureExt, Stream, StreamExt};
|
|
@@ -73,7 +73,7 @@ where
|
|
|
73
73
|
let mut client = if let Some(c) = self.client_override {
|
|
74
74
|
c
|
|
75
75
|
} else {
|
|
76
|
-
|
|
76
|
+
mock_manual_worker_client()
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
let hist_allow_tx = historator.replay_done_tx.clone();
|
|
@@ -114,7 +114,7 @@ where
|
|
|
114
114
|
hist_allow_tx.send("Failed".to_string()).unwrap();
|
|
115
115
|
async move { Ok(RespondWorkflowTaskFailedResponse::default()) }.boxed()
|
|
116
116
|
});
|
|
117
|
-
let mut worker = Worker::new(self.config, None, Arc::new(client), None);
|
|
117
|
+
let mut worker = Worker::new(self.config, None, Arc::new(client), None, None);
|
|
118
118
|
worker.set_post_activate_hook(post_activate);
|
|
119
119
|
shutdown_tok(worker.shutdown_token());
|
|
120
120
|
Ok(worker)
|