-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sequential reducers syntax in processing_strategy macro
- Loading branch information
1 parent
fbedfaa
commit fc26456
Showing
5 changed files
with
165 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod clickhouse; | ||
pub mod noop; | ||
pub mod os_stream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::{marker::PhantomData, time::Duration}; | ||
|
||
use tracing::info; | ||
|
||
use crate::{ | ||
ReduceConfig, ReduceShutdownBehaviour, ReduceShutdownCondition, Reducer, | ||
ReducerWhenFullBehaviour, | ||
}; | ||
|
||
pub struct NoopReducer<T> { | ||
phantom: PhantomData<T>, | ||
id: String, | ||
} | ||
|
||
impl<T> NoopReducer<T> { | ||
pub fn new(id: &str) -> Self { | ||
Self { | ||
phantom: PhantomData, | ||
id: id.into(), | ||
} | ||
} | ||
} | ||
|
||
impl<T> Reducer for NoopReducer<T> | ||
where | ||
T: Send, | ||
{ | ||
type Input = T; | ||
type Output = (); | ||
|
||
async fn reduce(&mut self, _t: Self::Input) -> Result<(), anyhow::Error> { | ||
Ok(()) | ||
} | ||
|
||
async fn flush(&mut self) -> Result<(), anyhow::Error> { | ||
info!("Noop reducer id: {} flushed", self.id); | ||
Ok(()) | ||
} | ||
|
||
fn reset(&mut self) {} | ||
|
||
fn is_full(&self) -> bool { | ||
false | ||
} | ||
|
||
fn get_reduce_config(&self) -> crate::ReduceConfig { | ||
ReduceConfig { | ||
shutdown_condition: ReduceShutdownCondition::Drain, | ||
shutdown_behaviour: ReduceShutdownBehaviour::Flush, | ||
when_full_behaviour: ReducerWhenFullBehaviour::Flush, | ||
flush_interval: Some(Duration::from_secs(1)), | ||
} | ||
} | ||
} |