Skip to content

Commit

Permalink
ref(rust): Align next_step parameters in strategy constructors (#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
loewenheim authored Dec 6, 2023
1 parent 877323a commit fa8ac3d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions rust_snuba/rust_arroyo/src/processing/strategies/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,19 @@ impl<T: Send + Sync, TResult: Clone + Send + Sync> ProcessingStrategy<T> for Red
}

impl<T, TResult: Clone> Reduce<T, TResult> {
pub fn new(
next_step: Box<dyn ProcessingStrategy<TResult>>,
pub fn new<N>(
next_step: N,
accumulator: Arc<dyn Fn(TResult, T) -> TResult + Send + Sync>,
initial_value: TResult,
max_batch_size: usize,
max_batch_time: Duration,
) -> Reduce<T, TResult> {
) -> Self
where
N: ProcessingStrategy<TResult> + 'static,
{
let batch_state = BatchState::new(initial_value.clone(), accumulator.clone());
Reduce {
next_step,
next_step: Box::new(next_step),
accumulator,
initial_value,
max_batch_size,
Expand Down Expand Up @@ -245,11 +248,11 @@ mod tests {
acc
});

let next_step = Box::new(NextStep {
let next_step = NextStep {
submitted: submitted_messages,
});
};

let mut strategy: Reduce<u64, Vec<u64>> = Reduce::new(
let mut strategy = Reduce::new(
next_step,
accumulator,
initial_value,
Expand Down

0 comments on commit fa8ac3d

Please sign in to comment.