pub struct ConsumerLogTruncationError { /* private fields */ }Expand description
In the event of an unclean leader election, the log will be truncated, previously committed data will be lost, and new data will be written over these offsets. When this happens, the consumer will detect the truncation and return this error (if no automatic reset policy has been defined) with the first offset known to diverge from what the consumer previously read.
Implementations§
Source§impl ConsumerLogTruncationError
impl ConsumerLogTruncationError
Sourcepub fn new(
offset_out_of_range_partitions: HashMap<TopicPartition, i64>,
divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Self
pub fn new( offset_out_of_range_partitions: HashMap<TopicPartition, i64>, divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> Self
Constructs a new ConsumerLogTruncationError with the fetch offsets and
divergent offsets.
§Arguments
offset_out_of_range_partitions- The fetch offsets that were out of rangedivergent_offsets- The offsets where the consumer’s log diverged from the broker’s log
Sourcepub fn with_message(
message: impl Into<String>,
offset_out_of_range_partitions: HashMap<TopicPartition, i64>,
divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Self
pub fn with_message( message: impl Into<String>, offset_out_of_range_partitions: HashMap<TopicPartition, i64>, divergent_offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> Self
Constructs a new ConsumerLogTruncationError with a custom message.
§Arguments
message- The detail messageoffset_out_of_range_partitions- The fetch offsets that were out of rangedivergent_offsets- The offsets where the consumer’s log diverged from the broker’s log
Sourcepub fn offset_out_of_range_partitions(&self) -> &HashMap<TopicPartition, i64>
pub fn offset_out_of_range_partitions(&self) -> &HashMap<TopicPartition, i64>
Get a map of the topic partitions and the respective out-of-range fetch offsets.
§Returns
The out-of-range fetch offset per partition
Sourcepub fn divergent_offsets(&self) -> &HashMap<TopicPartition, OffsetAndMetadata>
pub fn divergent_offsets(&self) -> &HashMap<TopicPartition, OffsetAndMetadata>
Get the divergent offsets for the partitions which were truncated. For each partition, this is the first offset which is known to diverge from what the consumer read.
Note that there is no guarantee that this offset will be known. It is
necessary to use Self::partitions to see the set of partitions that
were truncated and then check for the presence of a divergent offset in
this map.
§Returns
The divergent offset per partition
Sourcepub fn partitions(&self) -> impl Iterator<Item = &TopicPartition>
pub fn partitions(&self) -> impl Iterator<Item = &TopicPartition>
Trait Implementations§
Source§impl Clone for ConsumerLogTruncationError
impl Clone for ConsumerLogTruncationError
Source§fn clone(&self) -> ConsumerLogTruncationError
fn clone(&self) -> ConsumerLogTruncationError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more