lago-core 0.1.0

Foundation types, traits, and error definitions for the Lago agent runtime
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::error::LagoResult;
use crate::event::EventEnvelope;

/// A projection consumes events and builds derived state.
pub trait Projection: Send + Sync {
    /// Process a single event.
    fn on_event(&mut self, event: &EventEnvelope) -> LagoResult<()>;

    /// Called after replaying all existing events, before live tailing begins.
    fn on_replay_complete(&mut self) -> LagoResult<()> {
        Ok(())
    }

    /// Name of this projection (for logging/debugging).
    fn name(&self) -> &str;
}