Expand description
Event system for TAP HTTP server.
This module provides an event tracking and logging system for monitoring HTTP server activities. It allows tracking request/response activity, message processing, and server lifecycle events. Events can be logged to a configurable location (console, file, or custom handler).
§Features
- Track and log HTTP server events
- Request and response monitoring
- Configurable logging destination
- JSON structured logging support
- File rotation capabilities
- Integration with the TAP Node event system
§Example
use tap_http::{TapHttpConfig, TapHttpServer};
use tap_http::event::{EventLogger, EventLoggerConfig, LogDestination};
use tap_node::{NodeConfig, TapNode};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a TAP Node with default config
let node = TapNode::new(NodeConfig::default());
// Configure the HTTP server with event logging
let mut config = TapHttpConfig::default();
config.event_logger = Some(EventLoggerConfig {
destination: LogDestination::File {
path: "./logs/tap-http.log".to_string(),
max_size: Some(10 * 1024 * 1024), // 10 MB
rotate: true,
},
structured: true, // Use JSON format
log_level: tracing::Level::INFO,
});
// Create and start the server
let mut server = TapHttpServer::new(config, node);
server.start().await?;
Ok(())
}Structs§
- Event
Bus - Event bus for TAP HTTP server
- Event
Logger - Event logger for TAP HTTP server
- Event
Logger Config - Configuration for the event logger
Enums§
- Http
Event - HTTP server event types
- LogDestination
- Configuration for where event logs should be sent
Traits§
- Event
Subscriber - Event subscriber trait for TAP HTTP events
- Handle
Event - Helper trait for async handling