pub struct Transaction {
pub txn_id: TransactionId,
pub producer_id: ProducerId,
pub producer_epoch: ProducerEpoch,
pub state: TransactionState,
pub partitions: HashSet<TransactionPartition>,
pub pending_writes: Vec<PendingWrite>,
pub offset_commits: Vec<TransactionOffsetCommit>,
pub started_at: SystemTime,
pub timeout: Duration,
pub last_activity: Option<Instant>,
}Expand description
Active transaction state
Fields§
§txn_id: TransactionIdTransaction ID (unique per producer)
producer_id: ProducerIdProducer ID owning this transaction
producer_epoch: ProducerEpochProducer epoch (for fencing)
state: TransactionStateCurrent state
partitions: HashSet<TransactionPartition>Partitions involved in this transaction
pending_writes: Vec<PendingWrite>Pending writes (not yet committed)
offset_commits: Vec<TransactionOffsetCommit>Consumer offsets to commit with this transaction
started_at: SystemTimeTransaction start time
timeout: DurationTransaction timeout
last_activity: Option<Instant>Last activity timestamp
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(
txn_id: TransactionId,
producer_id: ProducerId,
producer_epoch: ProducerEpoch,
timeout: Duration,
) -> Self
pub fn new( txn_id: TransactionId, producer_id: ProducerId, producer_epoch: ProducerEpoch, timeout: Duration, ) -> Self
Create a new transaction
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Check if transaction has timed out
Sourcepub fn add_partition(&mut self, partition: TransactionPartition)
pub fn add_partition(&mut self, partition: TransactionPartition)
Add a partition to the transaction
Sourcepub fn add_write(
&mut self,
partition: TransactionPartition,
sequence: i32,
offset: u64,
)
pub fn add_write( &mut self, partition: TransactionPartition, sequence: i32, offset: u64, )
Record a pending write
Sourcepub fn add_offset_commit(
&mut self,
group_id: String,
offsets: Vec<(TransactionPartition, i64)>,
)
pub fn add_offset_commit( &mut self, group_id: String, offsets: Vec<(TransactionPartition, i64)>, )
Add consumer offset commit
Sourcepub fn write_count(&self) -> usize
pub fn write_count(&self) -> usize
Get total number of writes
Sourcepub fn affected_partitions(&self) -> impl Iterator<Item = &TransactionPartition>
pub fn affected_partitions(&self) -> impl Iterator<Item = &TransactionPartition>
Get all affected partitions
Trait Implementations§
Source§impl Clone for Transaction
impl Clone for Transaction
Source§fn clone(&self) -> Transaction
fn clone(&self) -> Transaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Transaction
impl Debug for Transaction
Source§impl<'de> Deserialize<'de> for Transaction
impl<'de> Deserialize<'de> for Transaction
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnwindSafe for Transaction
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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