#![allow(dead_code)]
use std::collections::HashMap;
#[derive(Debug, Clone, Default)]
pub struct Record {
pub topic: String,
pub key: Option<Vec<u8>>,
pub value: Vec<u8>,
pub headers: Vec<(String, Vec<u8>)>,
pub timestamp: Option<u64>,
}
impl Record {
pub fn new(topic: impl Into<String>) -> Self {
Self {
topic: topic.into(),
..Default::default()
}
}
pub fn key(mut self, key: impl Into<Vec<u8>>) -> Self {
self.key = Some(key.into());
self
}
pub fn value(mut self, value: impl Into<Vec<u8>>) -> Self {
self.value = value.into();
self
}
pub fn header(mut self, key: impl Into<String>, value: impl Into<Vec<u8>>) -> Self {
self.headers.push((key.into(), value.into()));
self
}
pub fn timestamp(mut self, ts: u64) -> Self {
self.timestamp = Some(ts);
self
}
}
#[derive(Debug, Clone)]
pub struct ConsumerRecord {
pub topic: String,
pub partition: u32,
pub offset: u64,
pub timestamp: u64,
pub key: Option<Vec<u8>>,
pub value: Vec<u8>,
pub headers: Vec<(String, Vec<u8>)>,
}
#[derive(Debug, Clone)]
pub struct RecordMetadata {
pub topic: String,
pub partition: u32,
pub offset: u64,
pub timestamp: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TopicPartition {
pub topic: String,
pub partition: u32,
}
impl TopicPartition {
pub fn new(topic: impl Into<String>, partition: u32) -> Self {
Self {
topic: topic.into(),
partition,
}
}
}
#[derive(Debug, Clone)]
pub struct OffsetAndMetadata {
pub offset: u64,
pub metadata: Option<String>,
}
impl OffsetAndMetadata {
pub fn new(offset: u64) -> Self {
Self {
offset,
metadata: None,
}
}
pub fn with_metadata(offset: u64, metadata: impl Into<String>) -> Self {
Self {
offset,
metadata: Some(metadata.into()),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Acks {
None = 0,
Leader = 1,
#[default]
All = -1,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum OffsetReset {
#[default]
Latest,
Earliest,
None,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum IsolationLevel {
#[default]
ReadUncommitted,
ReadCommitted,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Op {
Insert,
Update,
Delete,
}
#[derive(Debug, Clone)]
pub struct ChangeEvent {
pub table: String,
pub op: Op,
pub before: Option<serde_json::Value>,
pub after: Option<serde_json::Value>,
pub timestamp: u64,
pub tx_id: Option<String>,
}
#[derive(Debug, Clone)]
pub struct ConsumerGroupMetadata {
pub group_id: String,
pub generation_id: i32,
pub member_id: String,
}
#[derive(Debug, Clone, Default)]
pub struct PendingOptions {
pub start: Option<String>,
pub end: Option<String>,
pub count: Option<u32>,
pub consumer: Option<String>,
pub min_idle: Option<u64>,
}
#[derive(Debug, Clone)]
pub struct PendingInfo {
pub count: u64,
pub min_id: Option<String>,
pub max_id: Option<String>,
pub consumers: HashMap<String, u64>,
}
#[derive(Debug, Clone)]
pub struct PendingEntry {
pub id: String,
pub consumer: String,
pub idle_ms: u64,
pub delivery_count: u32,
}
#[derive(Debug, Clone, Default)]
pub struct ClaimOptions {
pub idle: Option<u64>,
pub time: Option<u64>,
pub retry_count: Option<u32>,
pub force: bool,
pub just_id: bool,
}
#[derive(Debug, Clone)]
pub struct AutoClaimResult {
pub next_id: String,
pub records: Vec<ConsumerRecord>,
pub deleted_ids: Vec<String>,
}