Trait vector::sinks::util::request_builder::RequestBuilder

source ·
pub trait RequestBuilder<Input> {
    type Metadata;
    type Events;
    type Encoder: Encoder<Self::Events>;
    type Payload: From<Bytes> + AsRef<[u8]>;
    type Request;
    type Error: From<Error>;

    // Required methods
    fn compression(&self) -> Compression;
    fn encoder(&self) -> &Self::Encoder;
    fn split_input(
        &self,
        input: Input,
    ) -> (Self::Metadata, RequestMetadataBuilder, Self::Events);
    fn build_request(
        &self,
        metadata: Self::Metadata,
        request_metadata: RequestMetadata,
        payload: EncodeResult<Self::Payload>,
    ) -> Self::Request;

    // Provided method
    fn encode_events(
        &self,
        events: Self::Events,
    ) -> Result<EncodeResult<Self::Payload>, Self::Error> { ... }
}
Expand description

Generalized interface for defining how a batch of events will be turned into a request.

Required Associated Types§

Required Methods§

source

fn compression(&self) -> Compression

Gets the compression algorithm used by this request builder.

source

fn encoder(&self) -> &Self::Encoder

Gets the encoder used by this request builder.

source

fn split_input( &self, input: Input, ) -> (Self::Metadata, RequestMetadataBuilder, Self::Events)

Splits apart the input into the metadata and event portions.

The metadata should be any information that needs to be passed back to build_request as-is, such as event finalizers, while the events are the actual events to process.

source

fn build_request( &self, metadata: Self::Metadata, request_metadata: RequestMetadata, payload: EncodeResult<Self::Payload>, ) -> Self::Request

Builds a request for the given metadata and payload.

Provided Methods§

source

fn encode_events( &self, events: Self::Events, ) -> Result<EncodeResult<Self::Payload>, Self::Error>

Implementors§