Skip to content

Commit 8e5ae54

Browse files
authored
Update API (#914)
commit 9263046461616e83f06fa3bdb3441f2142319024
1 parent 3a5ed35 commit 8e5ae54

54 files changed

Lines changed: 1044 additions & 1237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core-api/src/worker.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99
use temporal_sdk_core_protos::{
1010
coresdk,
1111
coresdk::{ActivitySlotInfo, LocalActivitySlotInfo, NexusSlotInfo, WorkflowSlotInfo},
12+
temporal,
1213
temporal::api::enums::v1::VersioningBehavior,
1314
};
1415

@@ -633,3 +634,12 @@ impl From<coresdk::common::WorkerDeploymentVersion> for WorkerDeploymentVersion
633634
}
634635
}
635636
}
637+
638+
impl From<temporal::api::deployment::v1::WorkerDeploymentVersion> for WorkerDeploymentVersion {
639+
fn from(v: temporal::api::deployment::v1::WorkerDeploymentVersion) -> Self {
640+
Self {
641+
deployment_name: v.deployment_name,
642+
build_id: v.build_id,
643+
}
644+
}
645+
}

core/src/core_tests/activity_tasks.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ async fn heartbeats_report_cancels_only_once() {
147147
Ok(RecordActivityTaskHeartbeatResponse {
148148
cancel_requested: true,
149149
activity_paused: false,
150+
activity_reset: false,
150151
})
151152
});
152153
mock_client
@@ -273,6 +274,7 @@ async fn activity_cancel_interrupts_poll() {
273274
Ok(RecordActivityTaskHeartbeatResponse {
274275
cancel_requested: true,
275276
activity_paused: false,
277+
activity_reset: false,
276278
})
277279
}
278280
.boxed()
@@ -394,11 +396,13 @@ async fn many_concurrent_heartbeat_cancels() {
394396
Ok(RecordActivityTaskHeartbeatResponse {
395397
cancel_requested: false,
396398
activity_paused: false,
399+
activity_reset: false,
397400
})
398401
} else {
399402
Ok(RecordActivityTaskHeartbeatResponse {
400403
cancel_requested: true,
401404
activity_paused: false,
405+
activity_reset: false,
402406
})
403407
}
404408
}
@@ -520,6 +524,7 @@ async fn can_heartbeat_acts_during_shutdown() {
520524
Ok(RecordActivityTaskHeartbeatResponse {
521525
cancel_requested: false,
522526
activity_paused: false,
527+
activity_reset: false,
523528
})
524529
});
525530
mock_client
@@ -574,6 +579,7 @@ async fn complete_act_with_fail_flushes_heartbeat() {
574579
Ok(RecordActivityTaskHeartbeatResponse {
575580
cancel_requested: false,
576581
activity_paused: false,
582+
activity_reset: false,
577583
})
578584
});
579585
mock_client
@@ -1254,6 +1260,7 @@ async fn heartbeat_response_can_be_paused() {
12541260
Ok(RecordActivityTaskHeartbeatResponse {
12551261
cancel_requested: false,
12561262
activity_paused: true,
1263+
activity_reset: false,
12571264
})
12581265
});
12591266
// Second heartbeat returns cancel only
@@ -1264,16 +1271,18 @@ async fn heartbeat_response_can_be_paused() {
12641271
Ok(RecordActivityTaskHeartbeatResponse {
12651272
cancel_requested: true,
12661273
activity_paused: false,
1274+
activity_reset: false,
12671275
})
12681276
});
1269-
// Third heartbeat returns both
1277+
// Third heartbeat does all 3
12701278
mock_client
12711279
.expect_record_activity_heartbeat()
12721280
.times(1)
12731281
.returning(|_, _| {
12741282
Ok(RecordActivityTaskHeartbeatResponse {
12751283
cancel_requested: true,
12761284
activity_paused: true,
1285+
activity_reset: true,
12771286
})
12781287
});
12791288
mock_client
@@ -1391,7 +1400,8 @@ async fn heartbeat_response_can_be_paused() {
13911400
task_token == &vec![3] &&
13921401
*reason == ActivityCancelReason::Cancelled as i32 &&
13931402
details.as_ref().is_some_and(|d| d.is_paused) &&
1394-
details.as_ref().is_some_and(|d| d.is_cancelled)
1403+
details.as_ref().is_some_and(|d| d.is_cancelled) &&
1404+
details.as_ref().is_some_and(|d| d.is_reset)
13951405
);
13961406
core.complete_activity_task(ActivityTaskCompletion {
13971407
task_token: act.task_token,

core/src/core_tests/workflow_tasks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,6 +2949,7 @@ async fn use_compatible_version_flag(
29492949
worker.shutdown().await;
29502950
}
29512951

2952+
#[allow(deprecated)]
29522953
#[tokio::test]
29532954
async fn sets_build_id_from_wft_complete() {
29542955
let wfid = "fake_wf_id";

core/src/worker/activities/activity_heartbeat_manager.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,15 @@ impl ActivityHeartbeatManager {
145145
.record_activity_heartbeat(tt.clone(), details.into_payloads())
146146
.await
147147
{
148-
Ok(RecordActivityTaskHeartbeatResponse { cancel_requested, activity_paused }) => {
149-
if cancel_requested || activity_paused {
150-
// Prioritize Cancel over Pause
148+
Ok(RecordActivityTaskHeartbeatResponse {
149+
cancel_requested, activity_paused, activity_reset
150+
}) => {
151+
if cancel_requested || activity_paused || activity_reset {
152+
// Prioritize Cancel / reset over pause
151153
let reason = if cancel_requested {
152154
ActivityCancelReason::Cancelled
155+
} else if activity_reset {
156+
ActivityCancelReason::Reset
153157
} else {
154158
ActivityCancelReason::Paused
155159
};
@@ -160,6 +164,7 @@ impl ActivityHeartbeatManager {
160164
ActivityCancellationDetails {
161165
is_cancelled: cancel_requested,
162166
is_paused: activity_paused,
167+
is_reset: activity_reset,
163168
..Default::default()
164169
}
165170
))

core/src/worker/workflow/machines/workflow_machines.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,17 +591,22 @@ impl WorkflowMachines {
591591
deployment_name: "".to_string(),
592592
build_id: "".to_string(),
593593
};
594+
#[allow(deprecated)]
594595
if let Some(bid) = $wtc.worker_version.as_ref().map(|wv| &wv.build_id) {
595596
combined_ver.build_id = bid.to_string();
596597
}
597598
if !$wtc.worker_deployment_name.is_empty() {
598599
combined_ver.deployment_name = $wtc.worker_deployment_name.clone();
599600
}
601+
#[allow(deprecated)]
600602
if !$wtc.worker_deployment_version.is_empty() {
601603
if let Ok(ver) = $wtc.worker_deployment_version.parse() {
602604
combined_ver = ver;
603605
}
604606
}
607+
if let Some(dv) = $wtc.deployment_version.as_ref() {
608+
combined_ver = dv.clone().into();
609+
}
605610
if !combined_ver.is_empty() {
606611
$me.current_wft_deployment_info = Some(combined_ver);
607612
}

sdk-core-protos/protos/api_upstream/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
3+
Copyright (c) 2025 Temporal Technologies Inc. All rights reserved.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)