pub struct SinkStack<L = ()> { /* private fields */ }Expand description
Builds a sink stack in record-entry order.
The first tier call becomes the outermost tier and receives
records first. Each later tier receives records only when the tier before
it forwards them; terminal finishes the stack with its
final sink.
The builder introduces no boxing, dynamic dispatch, runtime collection, or
store calls. Finishing it produces the existing nested Tier types.
use std::convert::Infallible;
use std::time::Duration;
use meathook::{
FlushPolicy, JsonlStore, MemStore, Sink, SinkStack, WindowMeta,
};
struct Terminal;
impl Sink<i32> for Terminal {
type Error = Infallible;
async fn ingest(
&mut self,
_: &WindowMeta,
_: Vec<i32>,
) -> Result<(), Self::Error> {
Ok(())
}
async fn flush(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
let sink = SinkStack::new()
.tier(
MemStore::new(),
FlushPolicy::new(Duration::from_secs(300), 10_000),
)
.tier(JsonlStore::new("spool"), FlushPolicy::hourly())
.terminal(Terminal);
// Concrete type, inferred without boxing or `dyn Sink`.
let _: meathook::Tier<
i32,
MemStore<i32>,
meathook::Tier<i32, JsonlStore<i32>, Terminal>,
> = sink;Implementations§
Source§impl<L> SinkStack<L>
impl<L> SinkStack<L>
Sourcepub fn tier<St>(
self,
store: St,
policy: FlushPolicy,
) -> SinkStack<(St, FlushPolicy, L)>
pub fn tier<St>( self, store: St, policy: FlushPolicy, ) -> SinkStack<(St, FlushPolicy, L)>
Add the next tier in record-entry order.
Sourcepub fn terminal<R, S>(self, sink: S) -> <L as BuildSinkStack<R, S>>::Outputwhere
S: Sink<R>,
L: BuildSinkStack<R, S>,
pub fn terminal<R, S>(self, sink: S) -> <L as BuildSinkStack<R, S>>::Outputwhere
S: Sink<R>,
L: BuildSinkStack<R, S>,
Finish the stack with its terminal sink.
The record type is normally inferred from the stores, terminal, or
surrounding pipeline. For a terminal that implements Sink for
multiple record types, specify it explicitly with
terminal::<MyRecord, _>(sink).
Trait Implementations§
Auto Trait Implementations§
impl<L> Freeze for SinkStack<L>where
L: Freeze,
impl<L> RefUnwindSafe for SinkStack<L>where
L: RefUnwindSafe,
impl<L> Send for SinkStack<L>where
L: Send,
impl<L> Sync for SinkStack<L>where
L: Sync,
impl<L> Unpin for SinkStack<L>where
L: Unpin,
impl<L> UnsafeUnpin for SinkStack<L>where
L: UnsafeUnpin,
impl<L> UnwindSafe for SinkStack<L>where
L: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more