Skip to main content

Collator

Struct Collator 

Source
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>

Source

pub fn new() -> Self

Create a new collator with default settings (emits both messages and exchanges)

Source

pub fn with_config(config: CollatorConfig) -> Self

Create a new collator with custom configuration

Source

pub fn with_max_buf_size(max_buf_size: usize) -> Self

Create a new collator with a custom maximum buffer size

Source

pub fn config(&self) -> &CollatorConfig

Get a reference to the current configuration

Source

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
Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<E: DataEvent> Default for Collator<E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<E> Freeze for Collator<E>

§

impl<E> !RefUnwindSafe for Collator<E>

§

impl<E> Send for Collator<E>
where E: Send,

§

impl<E> Sync for Collator<E>
where E: Sync,

§

impl<E> Unpin for Collator<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for Collator<E>

§

impl<E> UnwindSafe for Collator<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more