feat(engine): refactor funnel to allow skipping of events
This commit is contained in:
parent
379ab08cf1
commit
0b23a5cc30
|
@ -48,7 +48,10 @@ impl<'a> Funnel for DefaultFunnel<'a> {
|
||||||
.expect("invalid source index returned by select operation");
|
.expect("invalid source index returned by select operation");
|
||||||
|
|
||||||
// Receive (and convert) the event
|
// Receive (and convert) the event
|
||||||
let event = source.receive(op);
|
if let Some(event) = source.receive(op) {
|
||||||
FunnelResult::Event(event)
|
FunnelResult::Event(event)
|
||||||
|
} else {
|
||||||
|
FunnelResult::Skipped
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ mod default;
|
||||||
|
|
||||||
pub trait Source<'a> {
|
pub trait Source<'a> {
|
||||||
fn register(&'a self, select: &mut Select<'a>) -> usize;
|
fn register(&'a self, select: &mut Select<'a>) -> usize;
|
||||||
fn receive(&'a self, op: SelectedOperation) -> Event;
|
fn receive(&'a self, op: SelectedOperation) -> Option<Event>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Funnel {
|
pub trait Funnel {
|
||||||
|
@ -36,6 +36,7 @@ pub trait Funnel {
|
||||||
|
|
||||||
pub enum FunnelResult {
|
pub enum FunnelResult {
|
||||||
Event(Event),
|
Event(Event),
|
||||||
|
Skipped,
|
||||||
EndOfStream,
|
EndOfStream,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,9 @@ impl<'a> Engine<'a> {
|
||||||
debug!("end of stream received");
|
debug!("end of stream received");
|
||||||
return ExitMode::Exit;
|
return ExitMode::Exit;
|
||||||
}
|
}
|
||||||
|
FunnelResult::Skipped => {
|
||||||
|
// This event has been skipped, no need to handle it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user