riskless/messages/
commit_batch_request.rs

1#![allow(dead_code)]
2
3use crate::batch_coordinator::{TimestampType, TopicIdPartition};
4
5use super::batch_coordinate::BatchCoordinate;
6
7/// A request representing committing a batch to the BatchCoordinator for
8/// indexing.
9#[derive(Debug, Clone)]
10pub struct CommitBatchRequest {
11    /// The unique request ID.
12    pub request_id: u32,
13    /// The topic/partition combination.
14    pub topic_id_partition: TopicIdPartition,
15    /// The byte offset for this record.
16    pub byte_offset: u64,
17    /// The size retrieved for this record.
18    pub size: u32,
19    /// The base offset of the file.
20    pub base_offset: u64,
21    /// Unknown.
22    pub last_offset: u64,
23    /// Unknown.
24    pub batch_max_timestamp: u64,
25    /// Unknown.
26    pub message_timestamp_type: TimestampType,
27    /// The unique ID of the producer producing this batch.
28    pub producer_id: u64,
29    /// The producer's epoch.
30    pub producer_epoch: u16,
31    /// Unknown.
32    pub base_sequence: u32,
33    /// Unknown.
34    pub last_sequence: u32,
35}
36
37impl From<&BatchCoordinate> for CommitBatchRequest {
38    fn from(value: &BatchCoordinate) -> Self {
39        // Everything that is defaulted is unknown for now.
40        CommitBatchRequest {
41            request_id: value.request.request_id,
42            topic_id_partition: TopicIdPartition(value.topic.clone(), value.partition.clone()),
43            byte_offset: value.offset,
44            size: value.size,
45            base_offset: value.base_offset,
46            last_offset: Default::default(),
47            batch_max_timestamp: Default::default(),
48            message_timestamp_type: TimestampType::Dummy,
49            producer_id: Default::default(),
50            producer_epoch: Default::default(),
51            base_sequence: Default::default(),
52            last_sequence: Default::default(),
53        }
54    }
55}