Skip to content

Commit 07538f4

Browse files
committed
remove no_remote_activities
1 parent 7a7eb99 commit 07538f4

33 files changed

+141
-155
lines changed

crates/common/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ pub trait Worker: Send + Sync {
129129
/// [Worker::complete_workflow_activation] and [Worker::complete_activity_task] for those
130130
/// workflows & activities until they are done. At that point, the lang SDK can end the process,
131131
/// or drop the [Worker] instance via [Worker::finalize_shutdown], which will close the
132-
/// connection and free resources. If you have set [WorkerConfig::no_remote_activities], you may
133-
/// skip calling [Worker::poll_activity_task].
132+
/// connection and free resources. If you have set [WorkerConfig::task_types] to exclude
133+
/// [WorkerTaskTypes::ACTIVITIES], you may skip calling [Worker::poll_activity_task].
134134
///
135135
/// Lang implementations should use [Worker::initiate_shutdown] followed by
136136
/// [Worker::finalize_shutdown].

crates/common/src/worker.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,11 @@ pub struct WorkerConfig {
103103
/// By default, workers poll for all task types (workflows, activities, and nexus).
104104
/// You can restrict this to any combination. For example, a workflow-only worker would use
105105
/// `WorkerTaskTypes::WORKFLOWS`, while a worker handling activities and nexus but not workflows
106-
/// would use `WorkerTaskTypes::ACTIVITIES | WorkerTaskTypes::NEXUS`. If using in combination
107-
/// with `no_remote_activites`, it must be ensured that `ACTIVITIES` is not selected, as
108-
/// validation will fail.
106+
/// would use `WorkerTaskTypes::ACTIVITIES | WorkerTaskTypes::NEXUS`.
109107
///
110108
/// Note: At least one task type must be specified or the worker will fail validation.
111109
#[builder(default = "WorkerTaskTypes::all()")]
112110
pub task_types: WorkerTaskTypes,
113-
/// If set to true this worker will only handle workflow tasks and local activities, it will not
114-
/// poll for activity tasks. If this is used with `task_types`, users must ensure
115-
/// `WorkerTaskTypes::ACTIVITIES` is not set.
116-
///
117-
/// This is equivalent to setting
118-
/// `task_types = WorkerTaskTypes::WORKFLOWS | WorkerTaskTypes::NEXUS`.
119-
#[builder(default = "false")]
120-
pub no_remote_activities: bool,
121111
/// How long a workflow task is allowed to sit on the sticky queue before it is timed out
122112
/// and moved to the non-sticky queue where it may be picked up by any worker.
123113
#[builder(default = "Duration::from_secs(10)")]
@@ -225,18 +215,6 @@ pub struct WorkerConfig {
225215
}
226216

227217
impl WorkerConfig {
228-
/// Returns the effective task types this worker should poll for, taking into account
229-
/// `no_remote_activities` field.
230-
///
231-
/// If `no_remote_activities` is true, activities are excluded from the task types.
232-
pub fn effective_task_types(&self) -> WorkerTaskTypes {
233-
if self.no_remote_activities {
234-
self.task_types - WorkerTaskTypes::ACTIVITIES
235-
} else {
236-
self.task_types
237-
}
238-
}
239-
240218
/// Returns true if the configuration specifies we should fail a workflow on a certain error
241219
/// type rather than failing the workflow task.
242220
pub fn should_fail_workflow(
@@ -285,19 +263,6 @@ impl WorkerConfigBuilder {
285263
return Err("At least one task type must be enabled in `task_types`".to_owned());
286264
}
287265

288-
// Handle backward compatibility with no_remote_activities
289-
if let Some(true) = self.no_remote_activities {
290-
// If no_remote_activities is set to true, warn if task_types was also explicitly set
291-
// and includes activities
292-
if self.task_types.is_some() && task_types.contains(WorkerTaskTypes::ACTIVITIES) {
293-
return Err(
294-
"Conflicting configuration: `no_remote_activities` is true but `task_types` includes ACTIVITIES. \
295-
Please update `task_types` to not allow for ACTIVITIES."
296-
.to_owned(),
297-
);
298-
}
299-
}
300-
301266
if let Some(b) = self.workflow_task_poller_behavior.as_ref() {
302267
b.validate()?
303268
}

crates/common/tests/worker_task_types_test.rs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn test_default_configuration_polls_all_types() {
1515
.build()
1616
.expect("Failed to build default config");
1717

18-
let effective = config.effective_task_types();
18+
let effective = config.task_types;
1919
assert!(
2020
effective.polls_workflows(),
2121
"Should poll workflows by default"
@@ -38,7 +38,7 @@ fn test_workflow_only_worker() {
3838
.build()
3939
.expect("Failed to build workflow-only config");
4040

41-
let effective = config.effective_task_types();
41+
let effective = config.task_types;
4242
assert!(effective.polls_workflows(), "Should poll workflows");
4343
assert!(!effective.polls_activities(), "Should NOT poll activities");
4444
assert!(!effective.polls_nexus(), "Should NOT poll nexus");
@@ -55,28 +55,12 @@ fn test_activity_and_nexus_worker() {
5555
.build()
5656
.expect("Failed to build activity+nexus config");
5757

58-
let effective = config.effective_task_types();
58+
let effective = config.task_types;
5959
assert!(!effective.polls_workflows(), "Should NOT poll workflows");
6060
assert!(effective.polls_activities(), "Should poll activities");
6161
assert!(effective.polls_nexus(), "Should poll nexus");
6262
}
6363

64-
#[test]
65-
fn test_backward_compatibility_with_no_remote_activities() {
66-
let config = WorkerConfigBuilder::default()
67-
.namespace("default")
68-
.task_queue("test-queue")
69-
.versioning_strategy(default_versioning_strategy())
70-
.no_remote_activities(true)
71-
.build()
72-
.expect("Failed to build config with no_remote_activities");
73-
74-
let effective = config.effective_task_types();
75-
assert!(effective.polls_workflows(), "Should poll workflows");
76-
assert!(!effective.polls_activities(), "Should NOT poll activities");
77-
assert!(effective.polls_nexus(), "Should poll nexus");
78-
}
79-
8064
#[test]
8165
fn test_empty_task_types_fails_validation() {
8266
let result = WorkerConfigBuilder::default()
@@ -115,26 +99,6 @@ fn test_workflow_cache_without_workflows_fails() {
11599
);
116100
}
117101

118-
#[test]
119-
fn test_conflicting_no_remote_activities_and_task_types_fails() {
120-
#[allow(deprecated)]
121-
let result = WorkerConfigBuilder::default()
122-
.namespace("default")
123-
.task_queue("test-queue")
124-
.versioning_strategy(default_versioning_strategy())
125-
.task_types(WorkerTaskTypes::ACTIVITIES)
126-
.no_remote_activities(true)
127-
.build();
128-
129-
assert!(result.is_err(), "Conflicting settings should fail");
130-
131-
let err = result.err().unwrap().to_string();
132-
assert!(
133-
err.contains("Conflicting configuration"),
134-
"Error should mention conflict: {err}",
135-
);
136-
}
137-
138102
#[test]
139103
fn test_all_combinations() {
140104
let combinations = [
@@ -165,7 +129,7 @@ fn test_all_combinations() {
165129
.build()
166130
.unwrap_or_else(|e| panic!("Failed to build config for {description}: {e:?}"));
167131

168-
let effective = config.effective_task_types();
132+
let effective = config.task_types;
169133
assert_eq!(
170134
effective, task_types,
171135
"Effective types should match for {description}",

crates/sdk-core-c-bridge/src/worker.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub struct WorkerOptions {
4444
pub max_cached_workflows: u32,
4545
pub tuner: TunerHolder,
4646
pub task_types: u8,
47-
pub no_remote_activities: bool,
4847
pub sticky_queue_schedule_to_start_timeout_millis: u64,
4948
pub max_heartbeat_throttle_interval_millis: u64,
5049
pub default_heartbeat_throttle_interval_millis: u64,
@@ -1191,7 +1190,6 @@ impl TryFrom<&WorkerOptions> for temporalio_sdk_core::WorkerConfig {
11911190
temporalio_common::worker::WorkerTaskTypes::from_bits_truncate(opt.task_types)
11921191
}
11931192
})
1194-
.no_remote_activities(opt.no_remote_activities)
11951193
.sticky_queue_schedule_to_start_timeout(Duration::from_millis(
11961194
opt.sticky_queue_schedule_to_start_timeout_millis,
11971195
))

crates/sdk-core/src/core_tests/activity_tasks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use temporalio_common::{
5353
},
5454
test_utils::start_timer_cmd,
5555
},
56-
worker::PollerBehavior,
56+
worker::{PollerBehavior, WorkerTaskTypes},
5757
};
5858
use tokio::{join, time::sleep};
5959
use tokio_util::sync::CancellationToken;
@@ -725,7 +725,7 @@ async fn no_eager_activities_requested_when_worker_options_disable_it(
725725
mock.worker_cfg(|wc| {
726726
wc.max_cached_workflows = 2;
727727
if reason == "no_remote" {
728-
wc.no_remote_activities = true;
728+
wc.task_types = WorkerTaskTypes::WORKFLOWS;
729729
} else {
730730
wc.max_task_queue_activities_per_second = Some(1.0);
731731
}

crates/sdk-core/src/core_tests/workers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use temporalio_common::{
2929
},
3030
test_utils::start_timer_cmd,
3131
},
32-
worker::PollerBehavior,
32+
worker::{PollerBehavior, WorkerTaskTypes},
3333
};
3434
use tokio::sync::{Barrier, watch};
3535

@@ -135,7 +135,7 @@ async fn can_shutdown_local_act_only_worker_when_act_polling() {
135135
let mh = MockPollCfg::from_resp_batches("fakeid", t, [1], mock);
136136
let mut mock = build_mock_pollers(mh);
137137
mock.worker_cfg(|w| {
138-
w.no_remote_activities = true;
138+
w.task_types = WorkerTaskTypes::WORKFLOWS;
139139
w.max_cached_workflows = 1;
140140
});
141141
let worker = mock_worker(mock);

crates/sdk-core/src/core_tests/workflow_tasks.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use std::{
2828
time::Duration,
2929
};
3030
use temporalio_client::MESSAGE_TOO_LARGE_KEY;
31+
use temporalio_common::worker::WorkerTaskTypes;
3132
use temporalio_common::{
3233
Worker as WorkerTrait,
3334
errors::PollError,
@@ -2671,7 +2672,7 @@ async fn poller_wont_run_ahead_of_task_slots() {
26712672
.max_cached_workflows(10_usize)
26722673
.max_outstanding_workflow_tasks(10_usize)
26732674
.workflow_task_poller_behavior(PollerBehavior::SimpleMaximum(10_usize))
2674-
.no_remote_activities(true)
2675+
.task_types(WorkerTaskTypes::WORKFLOWS)
26752676
.build()
26762677
.unwrap(),
26772678
mock_client,
@@ -2731,7 +2732,7 @@ async fn poller_wont_poll_until_lang_polls() {
27312732

27322733
let worker = Worker::new_test(
27332734
test_worker_cfg()
2734-
.no_remote_activities(true)
2735+
.task_types(WorkerTaskTypes::WORKFLOWS)
27352736
.build()
27362737
.unwrap(),
27372738
mock_client,
@@ -2876,7 +2877,7 @@ async fn slot_provider_cant_hand_out_more_permits_than_cache_size() {
28762877
.build(),
28772878
))
28782879
.workflow_task_poller_behavior(PollerBehavior::SimpleMaximum(10_usize))
2879-
.no_remote_activities(true)
2880+
.task_types(WorkerTaskTypes::WORKFLOWS)
28802881
.build()
28812882
.unwrap(),
28822883
mock_client,
@@ -3024,7 +3025,7 @@ async fn both_normal_and_sticky_pollers_poll_concurrently() {
30243025
.max_outstanding_workflow_tasks(2_usize)
30253026
.workflow_task_poller_behavior(PollerBehavior::SimpleMaximum(2_usize))
30263027
.nonsticky_to_sticky_poll_ratio(0.2)
3027-
.no_remote_activities(true)
3028+
.task_types(WorkerTaskTypes::WORKFLOWS)
30283029
.build()
30293030
.unwrap(),
30303031
Some("stickytq".to_string()),

crates/sdk-core/src/replay/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::{
1919
pub use temporalio_common::protos::{
2020
DEFAULT_WORKFLOW_TYPE, HistoryInfo, TestHistoryBuilder, default_wes_attribs,
2121
};
22+
use temporalio_common::worker::WorkerTaskTypes;
2223
use temporalio_common::{
2324
protos::{
2425
coresdk::workflow_activation::remove_from_cache::EvictionReason,
@@ -62,7 +63,7 @@ where
6263
pub(crate) fn into_core_worker(mut self) -> Result<Worker, anyhow::Error> {
6364
self.config.max_cached_workflows = 1;
6465
self.config.workflow_task_poller_behavior = PollerBehavior::SimpleMaximum(1);
65-
self.config.no_remote_activities = true;
66+
self.config.task_types = WorkerTaskTypes::WORKFLOWS;
6667
self.config.skip_client_worker_set_check = true;
6768
let historator = Historator::new(self.history_stream);
6869
let post_activate = historator.get_post_activate_hook();

crates/sdk-core/src/test_help/integ_helpers.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use std::{
3636
task::{Context, Poll},
3737
time::Duration,
3838
};
39+
use temporalio_common::worker::WorkerTaskTypes;
3940
use temporalio_common::{
4041
Worker as WorkerTrait,
4142
errors::PollError,
@@ -184,10 +185,15 @@ pub fn build_fake_worker(
184185

185186
pub fn mock_worker(mocks: MocksHolder) -> Worker {
186187
let sticky_q = sticky_q_name_for_worker("unit-test", mocks.inputs.config.max_cached_workflows);
187-
let act_poller = if mocks.inputs.config.no_remote_activities {
188-
None
189-
} else {
188+
let act_poller = if mocks
189+
.inputs
190+
.config
191+
.task_types
192+
.contains(WorkerTaskTypes::ACTIVITIES)
193+
{
190194
mocks.inputs.act_poller
195+
} else {
196+
None
191197
};
192198
Worker::new_with_pollers(
193199
mocks.inputs.config,

crates/sdk-core/src/worker/heartbeat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{
55
use parking_lot::RwLock;
66
use std::{collections::HashMap, sync::Arc, time::Duration};
77
use temporalio_client::SharedNamespaceWorkerTrait;
8+
use temporalio_common::worker::WorkerTaskTypes;
89
use temporalio_common::{
910
protos::temporal::api::worker::v1::WorkerHeartbeat,
1011
worker::{PollerBehavior, WorkerConfigBuilder, WorkerVersioningStrategy},
@@ -38,7 +39,7 @@ impl SharedNamespaceWorker {
3839
"temporal-sys/worker-commands/{namespace}/{}",
3940
client.worker_grouping_key(),
4041
))
41-
.no_remote_activities(true)
42+
.task_types(WorkerTaskTypes::NEXUS)
4243
.max_outstanding_nexus_tasks(5_usize)
4344
.versioning_strategy(WorkerVersioningStrategy::None {
4445
build_id: "1.0".to_owned(),

0 commit comments

Comments
 (0)