pub struct EventHandlerRegistry { /* private fields */ }Expand description
Event handler registry
Manages a collection of event handlers and routes events to the appropriate handler. Supports batch processing for improved performance.
Implementations§
Source§impl EventHandlerRegistry
impl EventHandlerRegistry
Sourcepub fn with_batch_config(batch_config: BatchConfig) -> Self
pub fn with_batch_config(batch_config: BatchConfig) -> Self
Create a new registry with custom batch configuration
Sourcepub fn batch_config(&self) -> &BatchConfig
pub fn batch_config(&self) -> &BatchConfig
Get the batch configuration
Sourcepub fn set_batch_config(&mut self, config: BatchConfig)
pub fn set_batch_config(&mut self, config: BatchConfig)
Set the batch configuration
Sourcepub fn register(&mut self, handler: Box<dyn EventHandler>)
pub fn register(&mut self, handler: Box<dyn EventHandler>)
Register an event handler
Panics if a handler for the same event type is already registered.
Sourcepub fn try_register(&mut self, handler: Box<dyn EventHandler>) -> Result<()>
pub fn try_register(&mut self, handler: Box<dyn EventHandler>) -> Result<()>
Try to register a handler, returning error if already registered
Sourcepub fn get(&self, event_type: &str) -> Option<&dyn EventHandler>
pub fn get(&self, event_type: &str) -> Option<&dyn EventHandler>
Get a handler by event type
Sourcepub fn process(
&self,
conn: &Connection,
event_id: EventId,
event_bytes: &[u8],
) -> Result<()>
pub fn process( &self, conn: &Connection, event_id: EventId, event_bytes: &[u8], ) -> Result<()>
Process an event using the appropriate handler
Event format: event_type:payload
Example: deposit:100, withdraw:50
Sourcepub fn process_batched<'a, I>(
&self,
conn: &Connection,
events: I,
) -> Result<usize>
pub fn process_batched<'a, I>( &self, conn: &Connection, events: I, ) -> Result<usize>
Process multiple events in batches for improved performance
Groups events by type and processes each group in batches according to the batch configuration. Batches are flushed when either:
- The batch size limit is reached
- The batch duration limit is exceeded
§Arguments
conn: SQLite connection to use for all handlersevents: Iterator of (event_id, event_bytes) tuples
§Returns
Number of events successfully processed
Sourcepub fn event_types(&self) -> Vec<&str>
pub fn event_types(&self) -> Vec<&str>
List all registered event types