pub struct KafkaPartitions { /* private fields */ }Expand description
A subscription that takes exactly the partitions it names, without joining a consumer group and without rebalancing.
That fits a reader pinned to a partition, an inspection or replay tool, and a one-consumer-per-partition deployment. A group stays optional and changes only how offsets are handled: with one named the consumer commits into the group without joining it, and without one commits are off, so the start offset has to be explicit.
This form reads a subset of a topic, and the partitioner places a published record wherever
the key sends it, so no publish addresses it: a registration that retries names the
destination itself with .out_retry(policy).to("orders.retry"). Reading the whole topic is
KafkaTopic, which addresses its own copies.
§Examples
An inspection reader pinned to partition 0, with no group side effects:
use ruststream_rdkafka::context::keys::Offset;
use ruststream_rdkafka::prelude::*;
#[subscriber(KafkaPartitions::new("orders", [0]).start(StartOffset::Earliest))]
async fn inspect(order: &Order, Ctx(offset): Ctx<Offset>) -> HandlerOutcome {
tracing::info!(order.id, %offset, "read from partition 0");
HandlerOutcome::ack()
}
fn app() -> RustStream {
RustStream::new(AppInfo::new("inspector", "0.1.0"))
.with_broker(KafkaBroker::new(["localhost:9092"]), |b| {
b.include(inspect);
})
}Implementations§
Source§impl KafkaPartitions
impl KafkaPartitions
Sourcepub fn new(
topic: impl Into<String>,
partitions: impl IntoIterator<Item = i32>,
) -> Self
pub fn new( topic: impl Into<String>, partitions: impl IntoIterator<Item = i32>, ) -> Self
Describes a reader over exactly partitions of topic.
Sourcepub fn group(self, group: impl Into<String>) -> Self
pub fn group(self, group: impl Into<String>) -> Self
The consumer group whose committed offsets this reader uses, overriding
KafkaBroker::default_group. The reader commits
into the group without ever joining it.
Sourcepub fn start(self, start: StartOffset) -> Self
pub fn start(self, start: StartOffset) -> Self
Where the reader starts (see StartOffset). Without a group,
StartOffset::Committed has nothing to resume from and is a startup error.
Sourcepub fn commit(self, commit: Commit) -> Self
pub fn commit(self, commit: Commit) -> Self
How processed deliveries are committed (see Commit).
Commit::Transactional is a startup error here: an exactly-once pipeline commits
through the consumer-group protocol this form does not take part in.
Sourcepub fn lane_key(self, lane_key: LaneKey) -> Self
pub fn lane_key(self, lane_key: LaneKey) -> Self
What drives keyed worker lanes for this reader (see LaneKey). Under the default each
assigned partition gets a lane of its own.
Sourcepub fn config(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn config(self, key: impl Into<String>, value: impl Into<String>) -> Self
Raw librdkafka consumer property passthrough, applied last (it wins over the typed options and the broker-wide config).
A property the subscription’s Commit mode owns is the exception; see
KafkaTopic::config.
Sourcepub fn topic(&self) -> &str
pub fn topic(&self) -> &str
The topic these partitions belong to, which is also the handler metadata name.
Sourcepub fn partitions(&self) -> &[i32]
pub fn partitions(&self) -> &[i32]
The partitions this reader takes.
Trait Implementations§
Source§impl Clone for KafkaPartitions
impl Clone for KafkaPartitions
Source§impl Debug for KafkaPartitions
impl Debug for KafkaPartitions
Source§impl IntoSource for KafkaPartitions
impl IntoSource for KafkaPartitions
Source§type Source = KafkaPartitions
type Source = KafkaPartitions
Source§fn into_source(self) -> Self
fn into_source(self) -> Self
Source§impl SubscriptionSource<ConnectedKafkaBroker> for KafkaPartitions
impl SubscriptionSource<ConnectedKafkaBroker> for KafkaPartitions
Source§type Subscriber = KafkaSubscriber
type Subscriber = KafkaSubscriber
Source§type Copies = NamedCopies
type Copies = NamedCopies
AddressedCopies, NamedCopies or BrokerMoves. Read moreSource§async fn subscribe(
self,
connected: &ConnectedKafkaBroker,
) -> Result<Self::Subscriber, KafkaError>
async fn subscribe( self, connected: &ConnectedKafkaBroker, ) -> Result<Self::Subscriber, KafkaError>
Source§fn channel_bindings(&self) -> Bindings
fn channel_bindings(&self) -> Bindings
AsyncAPI document. Read moreSource§fn operation_bindings(&self) -> Bindings
fn operation_bindings(&self) -> Bindings
receive operation in the document. Read moreSource§fn declare_retry(self, declaration: &RetryDeclaration) -> Selfwhere
Self: Sized,
fn declare_retry(self, declaration: &RetryDeclaration) -> Selfwhere
Self: Sized,
Source§fn declare_retry_on(
&self,
connected: &C,
declaration: &RetryDeclaration,
) -> Result<(), DeclareRetryError>
fn declare_retry_on( &self, connected: &C, declaration: &RetryDeclaration, ) -> Result<(), DeclareRetryError>
Source§fn message_bindings(&self) -> Bindings
fn message_bindings(&self) -> Bindings
Auto Trait Implementations§
impl Freeze for KafkaPartitions
impl RefUnwindSafe for KafkaPartitions
impl Send for KafkaPartitions
impl Sync for KafkaPartitions
impl Unpin for KafkaPartitions
impl UnsafeUnpin for KafkaPartitions
impl UnwindSafe for KafkaPartitions
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