use super::super::{AppendRecordList, AppendResults};
use ozzy_proto::{
MessageId, Offset, OwnerEpoch, PartitionIncarnation, ProducerEpoch, ProducerId,
ProducerSequence,
};
use smallvec::SmallVec;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AppendRecord<'a> {
pub encoding: ozzy_proto::data::Encoding,
pub message_id: MessageId,
pub parts: SmallVec<[&'a [u8]; 2]>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AppendBatch<'a> {
pub partition: PartitionIncarnation,
pub owner_epoch: OwnerEpoch,
pub producer_id: ProducerId,
pub producer_epoch: ProducerEpoch,
pub first_sequence: ProducerSequence,
pub first_offset: Offset,
pub append_timestamp_millis: u64,
pub records: AppendRecordList<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Append<'a> {
pub batches: Vec<AppendBatch<'a>>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ResolvedAppend<'a> {
pub batch: AppendBatch<'a>,
pub results: AppendResults<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Schedule<'a> {
pub batch: AppendBatch<'a>,
pub first_schedule: u64,
pub due_millis: Vec<u64>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ReleaseKey {
pub millis: u64,
pub schedule: u64,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct HeldPosition {
pub operation: u64,
pub index: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Carry<'a> {
pub batch: AppendBatch<'a>,
pub from: HeldPosition,
pub through: HeldPosition,
pub keys: Vec<ReleaseKey>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Release<'a> {
pub batch: AppendBatch<'a>,
pub through: ReleaseKey,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AppendBatchSummary {
pub partition: PartitionIncarnation,
pub owner_epoch: OwnerEpoch,
pub producer_id: ProducerId,
pub producer_epoch: ProducerEpoch,
pub first_sequence: ProducerSequence,
pub first_offset: Offset,
pub record_count: usize,
pub nonzero_message_ids: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct RecordPosition {
pub descriptor: u32,
pub payload: u32,
pub parts: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AppendSummary {
pub(in crate::operation) batches: SmallVec<[AppendBatchSummary; 4]>,
}
impl AppendSummary {
pub fn single(batch: AppendBatchSummary) -> Self {
Self {
batches: smallvec::smallvec![batch],
}
}
pub fn batches(&self) -> &[AppendBatchSummary] {
&self.batches
}
}