@temporalio/core-bridge 1.4.3 → 1.4.4
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/package.json +2 -2
- 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/core/src/core_tests/activity_tasks.rs +77 -0
- package/sdk-core/core/src/test_help/mod.rs +6 -1
- package/sdk-core/core/src/worker/workflow/mod.rs +23 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/core-bridge",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Temporal.io SDK Core<>Node bridge",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "7ae3fba6332000b35d521411404c11e32052f282"
|
|
46
46
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -614,6 +614,83 @@ async fn max_tq_acts_set_passed_to_poll_properly() {
|
|
|
614
614
|
worker.poll_activity_task().await.unwrap();
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
+
/// This test doesn't test the real worker config since [mock_worker] bypasses the worker
|
|
618
|
+
/// constructor, [mock_worker] will not pass an activity poller to the worker when
|
|
619
|
+
/// `no_remote_activities` is set to `true`.
|
|
620
|
+
#[tokio::test]
|
|
621
|
+
async fn no_eager_activities_requested_when_worker_options_disable_remote_activities() {
|
|
622
|
+
let wfid = "fake_wf_id";
|
|
623
|
+
let mut t = TestHistoryBuilder::default();
|
|
624
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
625
|
+
t.add_full_wf_task();
|
|
626
|
+
let scheduled_event_id = t.add_activity_task_scheduled("act_id");
|
|
627
|
+
let started_event_id = t.add_activity_task_started(scheduled_event_id);
|
|
628
|
+
t.add_activity_task_completed(scheduled_event_id, started_event_id, b"hi".into());
|
|
629
|
+
t.add_full_wf_task();
|
|
630
|
+
t.add_workflow_execution_completed();
|
|
631
|
+
let num_eager_requested = Arc::new(AtomicUsize::new(0));
|
|
632
|
+
// Clone it to move into the callback below
|
|
633
|
+
let num_eager_requested_clone = num_eager_requested.clone();
|
|
634
|
+
|
|
635
|
+
let mut mock = mock_workflow_client();
|
|
636
|
+
mock.expect_complete_workflow_task()
|
|
637
|
+
.times(1)
|
|
638
|
+
.returning(move |req| {
|
|
639
|
+
// Store the number of eager activities requested to be checked below
|
|
640
|
+
let count = req
|
|
641
|
+
.commands
|
|
642
|
+
.into_iter()
|
|
643
|
+
.filter(|c| match c.attributes {
|
|
644
|
+
Some(Attributes::ScheduleActivityTaskCommandAttributes(
|
|
645
|
+
ScheduleActivityTaskCommandAttributes {
|
|
646
|
+
request_eager_execution,
|
|
647
|
+
..
|
|
648
|
+
},
|
|
649
|
+
)) => request_eager_execution,
|
|
650
|
+
_ => false,
|
|
651
|
+
})
|
|
652
|
+
.count();
|
|
653
|
+
num_eager_requested_clone.store(count, Ordering::Relaxed);
|
|
654
|
+
Ok(RespondWorkflowTaskCompletedResponse {
|
|
655
|
+
workflow_task: None,
|
|
656
|
+
activity_tasks: vec![],
|
|
657
|
+
})
|
|
658
|
+
});
|
|
659
|
+
let mut mock = single_hist_mock_sg(wfid, t, [1], mock, true);
|
|
660
|
+
let mut mock_poller = mock_manual_poller();
|
|
661
|
+
mock_poller
|
|
662
|
+
.expect_poll()
|
|
663
|
+
.returning(|| futures::future::pending().boxed());
|
|
664
|
+
mock.set_act_poller(Box::new(mock_poller));
|
|
665
|
+
mock.worker_cfg(|wc| {
|
|
666
|
+
wc.max_cached_workflows = 2;
|
|
667
|
+
wc.no_remote_activities = true;
|
|
668
|
+
});
|
|
669
|
+
let core = mock_worker(mock);
|
|
670
|
+
|
|
671
|
+
// Test start
|
|
672
|
+
let wf_task = core.poll_workflow_activation().await.unwrap();
|
|
673
|
+
let cmds = vec![ScheduleActivity {
|
|
674
|
+
seq: 1,
|
|
675
|
+
activity_id: "act_id".to_string(),
|
|
676
|
+
task_queue: TEST_Q.to_string(),
|
|
677
|
+
cancellation_type: ActivityCancellationType::TryCancel as i32,
|
|
678
|
+
..Default::default()
|
|
679
|
+
}
|
|
680
|
+
.into()];
|
|
681
|
+
|
|
682
|
+
core.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
683
|
+
wf_task.run_id,
|
|
684
|
+
cmds,
|
|
685
|
+
))
|
|
686
|
+
.await
|
|
687
|
+
.unwrap();
|
|
688
|
+
|
|
689
|
+
core.shutdown().await;
|
|
690
|
+
|
|
691
|
+
assert_eq!(num_eager_requested.load(Ordering::Relaxed), 0);
|
|
692
|
+
}
|
|
693
|
+
|
|
617
694
|
/// This test verifies that activity tasks which come as replies to completing a WFT are properly
|
|
618
695
|
/// delivered via polling.
|
|
619
696
|
#[tokio::test]
|
|
@@ -133,12 +133,17 @@ pub(crate) fn build_fake_worker(
|
|
|
133
133
|
|
|
134
134
|
pub(crate) fn mock_worker(mocks: MocksHolder) -> Worker {
|
|
135
135
|
let sticky_q = sticky_q_name_for_worker("unit-test", &mocks.inputs.config);
|
|
136
|
+
let act_poller = if mocks.inputs.config.no_remote_activities {
|
|
137
|
+
None
|
|
138
|
+
} else {
|
|
139
|
+
mocks.inputs.act_poller
|
|
140
|
+
};
|
|
136
141
|
Worker::new_with_pollers(
|
|
137
142
|
mocks.inputs.config,
|
|
138
143
|
sticky_q,
|
|
139
144
|
mocks.client,
|
|
140
145
|
mocks.inputs.wft_stream,
|
|
141
|
-
|
|
146
|
+
act_poller,
|
|
142
147
|
Default::default(),
|
|
143
148
|
CancellationToken::new(),
|
|
144
149
|
)
|
|
@@ -458,32 +458,34 @@ impl Workflows {
|
|
|
458
458
|
commands: &mut [Command],
|
|
459
459
|
) -> Vec<OwnedMeteredSemPermit> {
|
|
460
460
|
let mut reserved = vec![];
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
461
|
+
for cmd in commands {
|
|
462
|
+
if let Some(Attributes::ScheduleActivityTaskCommandAttributes(attrs)) =
|
|
463
|
+
cmd.attributes.as_mut()
|
|
464
|
+
{
|
|
465
|
+
// If request_eager_execution was already false, that means lang explicitly
|
|
466
|
+
// told us it didn't want to eagerly execute for some reason. So, we only
|
|
467
|
+
// ever turn *off* eager execution if a slot is not available or the activity
|
|
468
|
+
// is scheduled on a different task queue.
|
|
469
|
+
if attrs.request_eager_execution {
|
|
470
|
+
let same_task_queue = attrs
|
|
471
|
+
.task_queue
|
|
472
|
+
.as_ref()
|
|
473
|
+
.map(|q| q.name == self.task_queue)
|
|
474
|
+
.unwrap_or_default();
|
|
475
|
+
if same_task_queue
|
|
476
|
+
&& reserved.len() < MAX_EAGER_ACTIVITY_RESERVATIONS_PER_WORKFLOW_TASK
|
|
477
|
+
{
|
|
478
|
+
if let Some(p) = self
|
|
479
|
+
.activity_tasks_handle
|
|
473
480
|
.as_ref()
|
|
474
|
-
.
|
|
475
|
-
.unwrap_or_default();
|
|
476
|
-
if same_task_queue
|
|
477
|
-
&& reserved.len() < MAX_EAGER_ACTIVITY_RESERVATIONS_PER_WORKFLOW_TASK
|
|
481
|
+
.and_then(|h| h.reserve_slot())
|
|
478
482
|
{
|
|
479
|
-
|
|
480
|
-
reserved.push(p);
|
|
481
|
-
} else {
|
|
482
|
-
attrs.request_eager_execution = false;
|
|
483
|
-
}
|
|
483
|
+
reserved.push(p);
|
|
484
484
|
} else {
|
|
485
485
|
attrs.request_eager_execution = false;
|
|
486
486
|
}
|
|
487
|
+
} else {
|
|
488
|
+
attrs.request_eager_execution = false;
|
|
487
489
|
}
|
|
488
490
|
}
|
|
489
491
|
}
|