pub struct Message {
pub offset: u64,
pub key: Option<Bytes>,
pub value: Bytes,
pub timestamp: DateTime<Utc>,
pub headers: Vec<(String, Vec<u8>)>,
pub producer_id: Option<u64>,
pub producer_epoch: Option<u16>,
pub transaction_marker: Option<TransactionMarker>,
pub is_transactional: bool,
}Expand description
Represents a single message in Rivven
Fields§
§offset: u64Unique offset within the partition
key: Option<Bytes>Message key (optional, used for partitioning)
value: BytesMessage payload
timestamp: DateTime<Utc>Timestamp when message was created
headers: Vec<(String, Vec<u8>)>Optional headers for metadata
producer_id: Option<u64>Producer ID (for transactional/idempotent messages) None for non-transactional messages
producer_epoch: Option<u16>Producer epoch (for fencing)
transaction_marker: Option<TransactionMarker>Transaction marker (Some for control records, None for data records) Control records mark transaction boundaries (COMMIT/ABORT)
is_transactional: boolWhether this message is part of an ongoing transaction Used for read_committed filtering
Implementations§
Source§impl Message
impl Message
Sourcepub fn transactional(
value: Bytes,
producer_id: u64,
producer_epoch: u16,
) -> Self
pub fn transactional( value: Bytes, producer_id: u64, producer_epoch: u16, ) -> Self
Create a transactional message
Sourcepub fn transactional_with_key(
key: Bytes,
value: Bytes,
producer_id: u64,
producer_epoch: u16,
) -> Self
pub fn transactional_with_key( key: Bytes, value: Bytes, producer_id: u64, producer_epoch: u16, ) -> Self
Create a transactional message with a key
Sourcepub fn control_record(
marker: TransactionMarker,
producer_id: u64,
producer_epoch: u16,
) -> Self
pub fn control_record( marker: TransactionMarker, producer_id: u64, producer_epoch: u16, ) -> Self
Create a transaction control record (COMMIT or ABORT marker)
Sourcepub fn is_control_record(&self) -> bool
pub fn is_control_record(&self) -> bool
Check if this is a control record (transaction marker)
Sourcepub fn is_committed(&self) -> bool
pub fn is_committed(&self) -> bool
Check if this message is from a committed transaction Note: This is set after transaction completion, not during write
Sourcepub fn add_header(self, key: String, value: Vec<u8>) -> Self
pub fn add_header(self, key: String, value: Vec<u8>) -> Self
Add a header to the message
Sourcepub fn with_producer(
self,
producer_id: u64,
producer_epoch: u16,
transactional: bool,
) -> Self
pub fn with_producer( self, producer_id: u64, producer_epoch: u16, transactional: bool, ) -> Self
Mark as transactional
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize from bytes
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl !Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more