pub trait Callback: Send + Sync {
// Required method
fn on_completion(
self: Box<Self>,
metadata: Option<&RecordMetadata>,
error: Option<&Error>,
);
}Expand description
A callback interface that the user can implement to allow code to execute when the request is complete. This callback will generally execute in the background I/O task so it should be fast.
§Translation notes
callback::new builds one from a closure, invoked exactly once.
Required Methods§
Sourcefn on_completion(
self: Box<Self>,
metadata: Option<&RecordMetadata>,
error: Option<&Error>,
)
fn on_completion( self: Box<Self>, metadata: Option<&RecordMetadata>, error: Option<&Error>, )
A callback method the user can implement to provide asynchronous
handling of request completion. This method will be called when the
record sent to the server has been acknowledged. When error is not
None in the callback, metadata will contain the special -1 value for
all fields. If the topic partition cannot be chosen, a -1 value will be
assigned.
§Arguments
-
metadata- The metadata for the record that was sent (i.e. the partition and offset). An empty metadata with -1 value for all fields will be returned if an error occurred. -
error- The error raised during processing of this record.Noneif no error occurred. Possible errors include:Non-retriable errors (fatal, the message will never be sent):
InvalidTopicError,OffsetMetadataTooLargeError,RecordBatchTooLargeError,RecordTooLargeError,UnknownServerError,UnknownProducerIdError,InvalidProducerEpochError,AuthenticationError,AuthorizationError.Retriable errors (transient, may be covered by increasing
retries):CorruptRecordError,InvalidMetadataError,NotEnoughReplicasAfterAppendError,NotEnoughReplicasError,OffsetOutOfRangeError,TimeoutError,UnknownTopicOrPartitionError,ProducerBufferExhaustedError.