Trait vector::sinks::util::request_builder::IncrementalRequestBuilder
source · pub trait IncrementalRequestBuilder<Input> {
type Metadata;
type Payload;
type Request;
type Error;
// Required methods
fn encode_events_incremental(
&mut self,
input: Input,
) -> Vec<Result<(Self::Metadata, Self::Payload), Self::Error>>;
fn build_request(
&mut self,
metadata: Self::Metadata,
payload: Self::Payload,
) -> Self::Request;
}
Expand description
Generalized interface for defining how a batch of events will incrementally be turned into requests.
As opposed to RequestBuilder
, this trait provides the means to incrementally build requests
from a single batch of events, where all events in the batch may not fit into a single request.
This can be important for sinks where the underlying service has limitations on the size of a
request, or how many events may be present, necessitating a batch be split up into multiple requests.
While batches can be limited in size before being handed off to a request builder, we can’t always know in advance how large the encoded payload will be, which requires us to be able to potentially split a batch into multiple requests.
Required Associated Types§
Required Methods§
sourcefn encode_events_incremental(
&mut self,
input: Input,
) -> Vec<Result<(Self::Metadata, Self::Payload), Self::Error>>
fn encode_events_incremental( &mut self, input: Input, ) -> Vec<Result<(Self::Metadata, Self::Payload), Self::Error>>
Incrementally encodes the given input, potentially generating multiple payloads.
sourcefn build_request(
&mut self,
metadata: Self::Metadata,
payload: Self::Payload,
) -> Self::Request
fn build_request( &mut self, metadata: Self::Metadata, payload: Self::Payload, ) -> Self::Request
Builds a request for the given metadata and payload.