pub struct Collator<E: DataEvent> { /* private fields */ }Expand description
Collates individual data events into complete request/response exchanges.
Generic over the event type E which must implement DataEvent.
Uses per-connection locking via DashMap so concurrent HTTP/2 connections
do not serialize through a single mutex.
Implementations§
Source§impl<E: DataEvent> Collator<E>
impl<E: DataEvent> Collator<E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new collator with default settings (emits both messages and exchanges)
Sourcepub fn with_config(config: CollatorConfig) -> Self
pub fn with_config(config: CollatorConfig) -> Self
Create a new collator with custom configuration
Sourcepub fn with_max_buf_size(max_buf_size: usize) -> Self
pub fn with_max_buf_size(max_buf_size: usize) -> Self
Create a new collator with a custom maximum buffer size
Sourcepub fn config(&self) -> &CollatorConfig
pub fn config(&self) -> &CollatorConfig
Get a reference to the current configuration
Sourcepub fn add_event(&self, event: E) -> Vec<CollationEvent>
pub fn add_event(&self, event: E) -> Vec<CollationEvent>
Process a data event, returning all resulting collation events.
Takes ownership of the event to enable zero-copy transfer of the
payload into DataChunk via into_payload().
Returns Vec because:
- HTTP/2 can have multiple streams complete in one buffer
- A single buffer might contain complete request AND start of next
- Config might emit both messages AND exchanges
Sourcepub fn cleanup(&self, current_time_ns: TimestampNs)
pub fn cleanup(&self, current_time_ns: TimestampNs)
Clean up stale connections and evict stale H2 streams.
Callers should invoke this periodically to bound memory usage from abandoned connections and incomplete HTTP/2 streams.
Sourcepub fn remove_connection(&self, connection_id: u64, process_id: u32)
pub fn remove_connection(&self, connection_id: u64, process_id: u32)
Remove a connection explicitly (e.g., on connection close)
Call this when a connection is closed to free resources immediately. If connection_id is 0, removes based on process_id from SSL connections.
Sourcepub fn close_connection(
&self,
connection_id: u64,
process_id: u32,
) -> Vec<CollationEvent>
pub fn close_connection( &self, connection_id: u64, process_id: u32, ) -> Vec<CollationEvent>
Close a connection, finalizing any pending HTTP/1 response.
For HTTP/1 responses without explicit framing (no Content-Length or Transfer-Encoding), RFC 7230 §3.3.3 says the body extends until the connection closes. This method finalizes such responses with whatever body has accumulated so far, emits any resulting events, then removes the connection.