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");
|
||||
|
||||
// Receive (and convert) the event
|
||||
let event = source.receive(op);
|
||||
if let Some(event) = source.receive(op) {
|
||||
FunnelResult::Event(event)
|
||||
} else {
|
||||
FunnelResult::Skipped
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ mod default;
|
|||
|
||||
pub trait Source<'a> {
|
||||
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 {
|
||||
|
@ -36,6 +36,7 @@ pub trait Funnel {
|
|||
|
||||
pub enum FunnelResult {
|
||||
Event(Event),
|
||||
Skipped,
|
||||
EndOfStream,
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,9 @@ impl<'a> Engine<'a> {
|
|||
debug!("end of stream received");
|
||||
return ExitMode::Exit;
|
||||
}
|
||||
FunnelResult::Skipped => {
|
||||
// This event has been skipped, no need to handle it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user