Skip to content

Commit 7397c8d

Browse files
committed
set_params default implementation
1 parent 3b354f0 commit 7397c8d

5 files changed

Lines changed: 6 additions & 41 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ impl Node<WorkflowState> for ProcessorNode {
4343
type PrepResult = String;
4444
type ExecResult = bool;
4545

46-
fn set_params(&mut self, _params: Self::Params) {}
47-
4846
async fn prep(&self, store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
4947
let input: String = store.get("input").unwrap_or_default();
5048
Ok(input)
@@ -116,8 +114,6 @@ impl Node<String> for EmailProcessor {
116114
type PrepResult = String;
117115
type ExecResult = bool;
118116

119-
fn set_params(&mut self, _params: Self::Params) {}
120-
121117
async fn prep(&self, storage: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
122118
// Load email data from storage
123119
let email: String = storage.get("email").unwrap_or_default();

benches/flow_performance.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ impl Node<TestState> for DoNothingNode {
3737
type PrepResult = ();
3838
type ExecResult = ();
3939

40-
fn set_params(&mut self, _params: Self::Params) {}
41-
4240
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
4341
Ok(())
4442
}

benches/node_performance.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ impl Node<TestState> for DoNothingNode {
3131
type PrepResult = ();
3232
type ExecResult = ();
3333

34-
fn set_params(&mut self, _params: Self::Params) {}
35-
3634
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
3735
Ok(())
3836
}
@@ -74,8 +72,6 @@ impl Node<TestState> for CpuIntensiveNode {
7472
type PrepResult = Vec<u64>;
7573
type ExecResult = u64;
7674

77-
fn set_params(&mut self, _params: Self::Params) {}
78-
7975
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
8076
// Generate some data to process
8177
Ok((0..self.iterations as u64).collect())
@@ -120,8 +116,6 @@ impl Node<TestState> for IoSimulationNode {
120116
type PrepResult = String;
121117
type ExecResult = String;
122118

123-
fn set_params(&mut self, _params: Self::Params) {}
124-
125119
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
126120
// Simulate I/O delay
127121
tokio::time::sleep(tokio::time::Duration::from_millis(self.delay_ms)).await;

src/flow.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ where
149149
/// type PrepResult = String;
150150
/// type ExecResult = bool;
151151
///
152-
/// fn set_params(&mut self, _params: Self::Params) {}
153-
///
154152
/// async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
155153
/// Ok("prepared".to_string())
156154
/// }
@@ -176,8 +174,6 @@ where
176174
/// type PrepResult = i32;
177175
/// type ExecResult = i32;
178176
///
179-
/// fn set_params(&mut self, _params: Self::Params) {}
180-
///
181177
/// async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
182178
/// Ok(42)
183179
/// }
@@ -423,8 +419,6 @@ mod tests {
423419
type PrepResult = String;
424420
type ExecResult = bool;
425421

426-
fn set_params(&mut self, _params: Self::Params) {}
427-
428422
async fn prep(&self, store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
429423
// Try to get previous data or create default
430424
let data = store
@@ -476,8 +470,6 @@ mod tests {
476470
type PrepResult = String;
477471
type ExecResult = bool;
478472

479-
fn set_params(&mut self, _params: Self::Params) {}
480-
481473
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
482474
Err(CanoError::preparation(&self.error_message))
483475
}
@@ -520,8 +512,6 @@ mod tests {
520512
type PrepResult = ();
521513
type ExecResult = String;
522514

523-
fn set_params(&mut self, _params: Self::Params) {}
524-
525515
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
526516
Ok(())
527517
}
@@ -572,8 +562,6 @@ mod tests {
572562
type PrepResult = String;
573563
type ExecResult = bool;
574564

575-
fn set_params(&mut self, _params: Self::Params) {}
576-
577565
async fn prep(&self, store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
578566
store.get::<String>(&self.key_to_check).map_err(|e| {
579567
CanoError::preparation(format!("Failed to get key '{}': {}", self.key_to_check, e))

src/node.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ pub type NodeResult = DefaultNodeResult;
8787
/// type PrepResult = String;
8888
/// type ExecResult = bool;
8989
///
90-
/// fn set_params(&mut self, _params: Self::Params) {}
91-
///
9290
/// fn config(&self) -> NodeConfig {
9391
/// NodeConfig::minimal() // Use minimal retries for fast execution
9492
/// }
@@ -126,7 +124,12 @@ where
126124
type ExecResult: Send + Sync;
127125

128126
/// Set parameters for the node
129-
fn set_params(&mut self, params: Self::Params);
127+
///
128+
/// Default implementation that does nothing. Override this method if your node
129+
/// needs to store or process parameters when they are set.
130+
fn set_params(&mut self, _params: Self::Params) {
131+
// Default implementation does nothing
132+
}
130133

131134
/// Get the node configuration that controls execution behavior
132135
///
@@ -367,8 +370,6 @@ mod tests {
367370
type PrepResult = String;
368371
type ExecResult = bool;
369372

370-
fn set_params(&mut self, _params: Self::Params) {}
371-
372373
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
373374
Ok("prepared".to_string())
374375
}
@@ -411,8 +412,6 @@ mod tests {
411412
type PrepResult = String;
412413
type ExecResult = bool;
413414

414-
fn set_params(&mut self, _params: Self::Params) {}
415-
416415
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
417416
Err(CanoError::preparation(&self.error_message))
418417
}
@@ -454,8 +453,6 @@ mod tests {
454453
type PrepResult = Option<String>;
455454
type ExecResult = String;
456455

457-
fn set_params(&mut self, _params: Self::Params) {}
458-
459456
async fn prep(&self, store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
460457
match store.get::<String>(&self.read_key) {
461458
Ok(value) => Ok(Some(value)),
@@ -544,8 +541,6 @@ mod tests {
544541
type PrepResult = ();
545542
type ExecResult = ();
546543

547-
fn set_params(&mut self, _params: Self::Params) {}
548-
549544
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
550545
Ok(())
551546
}
@@ -581,8 +576,6 @@ mod tests {
581576
type PrepResult = String;
582577
type ExecResult = String;
583578

584-
fn set_params(&mut self, _params: Self::Params) {}
585-
586579
async fn prep(&self, _store: &Self::Storage) -> Result<Self::PrepResult, CanoError> {
587580
Ok("prep_completed".to_string())
588581
}
@@ -937,8 +930,6 @@ mod tests {
937930
type PrepResult = ();
938931
type ExecResult = ();
939932

940-
fn set_params(&mut self, _params: Self::Params) {}
941-
942933
fn config(&self) -> NodeConfig {
943934
NodeConfig::new().with_retries(self.max_retries, Duration::from_millis(1))
944935
}
@@ -996,8 +987,6 @@ mod tests {
996987
type PrepResult = ();
997988
type ExecResult = ();
998989

999-
fn set_params(&mut self, _params: Self::Params) {}
1000-
1001990
fn config(&self) -> NodeConfig {
1002991
NodeConfig::minimal()
1003992
}

0 commit comments

Comments
 (0)