pub trait IncrementalEncoder {
// Required methods
fn process_event<'life0, 'async_trait>(
&'life0 mut self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<ProcessResult, GenericError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn flush<'life0, 'life1, 'async_trait>(
&'life0 mut self,
dispatcher: &'life1 PayloadsDispatcher,
) -> Pin<Box<dyn Future<Output = Result<(), GenericError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
An incremental encoder.
Incremental encoders represent the essential operations of a encoder: adding events and flushing the resulting payloads. Generally, encoders should not need to concern themselves with the high-level details of being a component within a topology, such as responding to health probes, handling graceful shutdown, and so on. Through separating out the core encoder functionality from the component functionality, we can make it easier to implement various encoder implementations while only maintaining a few common encoder components that actually drive the underlying encoder logic.
Required Methods§
Sourcefn process_event<'life0, 'async_trait>(
&'life0 mut self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<ProcessResult, GenericError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn process_event<'life0, 'async_trait>(
&'life0 mut self,
event: Event,
) -> Pin<Box<dyn Future<Output = Result<ProcessResult, GenericError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Process a single event.
The encoder will process the event, attempting to add it to the current payload. If the encoder is unable to
process the event without flushing first, Ok(ProcessResult::FlushRequired(event))
is returned, containing the
event that could not be processed. Otherwise, Ok(ProcessResult::Continue)
is returned.
§Errors
If the encoder cannot process the event due to an unrecoverable error, an error is returned.
Sourcefn flush<'life0, 'life1, 'async_trait>(
&'life0 mut self,
dispatcher: &'life1 PayloadsDispatcher,
) -> Pin<Box<dyn Future<Output = Result<(), GenericError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn flush<'life0, 'life1, 'async_trait>(
&'life0 mut self,
dispatcher: &'life1 PayloadsDispatcher,
) -> Pin<Box<dyn Future<Output = Result<(), GenericError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Flush the encoder, finalizing all current payloads and sending them to the dispatcher.
§Errors
If the encoder cannot flush the payloads, an error is returned.