pub struct TransactionalPartitions { /* private fields */ }Expand description
Transactional publishers, one per source partition, materialized on first use.
Kafka permits one open transaction per producer and one live producer per transactional id
(initializing a second fences the first), so concurrent transactional handlers need one
producer each. The source partition is the natural scope: under the default
LaneKey::Partition worker pool a partition’s deliveries
process serially on one lane, so a publisher per partition gives every lane an independent
transaction with no coordination. The id set ("{base}-p{partition}") follows the topic’s
partitions rather than the worker count: changing workers(n) neither changes the ids nor
weakens zombie fencing - the scheme Kafka Streams uses for its per-task producers.
Not for LaneKey::RecordKey pools: record-key lanes spread
one partition across lanes, so two lanes would share a partition’s publisher and collide
on its single transaction (KafkaError::TransactionBusy).
Clones share the cache, so one injected handle serves every handler invocation.
Implementations§
Source§impl TransactionalPartitions
impl TransactionalPartitions
Sourcepub async fn for_partition(
&self,
partition: i32,
) -> Result<KafkaTransactionalPublisher, KafkaError>
pub async fn for_partition( &self, partition: i32, ) -> Result<KafkaTransactionalPublisher, KafkaError>
The publisher owning partition’s transactional id, created and initialized on first
use.
partition is the delivery’s source partition (KafkaContext’s Partition field in a
handler); passing anything else still works but forfeits the serialization argument
that makes the per-partition scope safe.
§Errors
Returns KafkaError::Closed once the broker has shut down and
KafkaError::Publish when the partition’s producer cannot be created or its
transactions cannot be initialized.
§Panics
Panics when the internal cache mutex is poisoned, which requires a prior panic while materializing a publisher (an invariant violation, not an operational failure).
Trait Implementations§
Source§impl Clone for TransactionalPartitions
impl Clone for TransactionalPartitions
Source§impl Debug for TransactionalPartitions
impl Debug for TransactionalPartitions
Source§impl PartitionLanes for TransactionalPartitions
impl PartitionLanes for TransactionalPartitions
Source§type Publisher = KafkaTransactionalPublisher
type Publisher = KafkaTransactionalPublisher
Source§fn for_partition(
&self,
partition: i32,
) -> impl Future<Output = Result<KafkaTransactionalPublisher, KafkaError>> + Send
fn for_partition( &self, partition: i32, ) -> impl Future<Output = Result<KafkaTransactionalPublisher, KafkaError>> + Send
partition’s transactional id. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TransactionalPartitions
impl !UnwindSafe for TransactionalPartitions
impl Freeze for TransactionalPartitions
impl Send for TransactionalPartitions
impl Sync for TransactionalPartitions
impl Unpin for TransactionalPartitions
impl UnsafeUnpin for TransactionalPartitions
Blanket Implementations§
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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