Expand description
Template lifecycle events and hooks for monitoring template cache behavior.
This module provides an event system for tracking template operations in real-time. Users can register callbacks to be notified when templates are learned, evicted, expire, collide, or when data arrives for missing templates.
§Use Cases
- Monitoring: Track template learning and eviction patterns
- Alerting: Detect template collisions that indicate configuration issues
- Metrics: Integrate with observability systems (Prometheus, StatsD, etc.)
- Debugging: Log template lifecycle events for troubleshooting
- Dynamic behavior: React to template events with custom logic
§Examples
use netflow_parser::{NetflowParser, TemplateEvent, TemplateProtocol};
let parser = NetflowParser::builder()
.on_template_event(|event| {
match event {
TemplateEvent::Learned { template_id, protocol } => {
println!("Learned template {} for {:?}", template_id, protocol);
}
TemplateEvent::Collision { template_id, protocol } => {
eprintln!("⚠️ Collision on template {} for {:?}", template_id, protocol);
}
_ => {}
}
})
.build()
.unwrap();Structs§
- Template
Hooks - Container for registered template event hooks.
Enums§
- Template
Event - Template lifecycle events.
- Template
Protocol - Protocol type for template events.
Type Aliases§
- Template
Hook - Type alias for template event hooks.