Skip to main content

ConsumerReady

Struct ConsumerReady 

Source
pub struct ConsumerReady<T> { /* private fields */ }
Expand description

Stage 3: everything required is present; the rest is optional.

Implementations§

Source§

impl<T: Transport> ConsumerReady<T>

Source

pub fn isolation(self, isolation: IsolationLevel) -> Self

Defaults to IsolationLevel::ReadCommitted — the safe end, since READ_UNCOMMITTED shows records from transactions that later aborted.

Source

pub fn credentials(self, credentials: Credentials) -> Self

SASL credentials. Pair PLAIN with TLS; it sends the password in the clear.

Source

pub fn assign( self, topic: impl Into<String>, partition: i32, start: StartOffset, ) -> Self

Assign a partition and where to start it. Call it once per partition.

Assignment is the caller’s: there is no consumer group and no rebalance, so nothing assigns partitions behind your back.

Source

pub fn assign_range( self, topic: impl Into<String>, partitions: impl IntoIterator<Item = i32>, start: StartOffset, ) -> Self

Assign a range of partitions, all starting at the same place.

Source

pub fn assign_all(self, topic: impl Into<String>, start: StartOffset) -> Self

Assign every partition of topic, asking the broker how many there are.

The count is the one thing about an assignment worth asking for: it changes when a topic is expanded, and hardcoding it in an assign_range silently stops consuming the new partitions. Which partitions this client owns is still the caller’s — there is no consumer group here, so a process that wants a share of a topic rather than all of it assigns that share itself.

Resolved once, at build, and that is a real hazard for a topic you do not own. Adding partitions is how a topic is scaled, and it is usually done by whoever produces to it. A topic expanded from 8 to 16 partitions after this call leaves partitions 8–15 unread indefinitely: nothing errors, and the consumer looks healthy while missing a share of its input.

Until this client can watch for that — see docs/completing-the-client.md, which is where the fix is scoped — assign_all means all of them as of now, and a caller reading a topic owned by someone else should poll Consumer::partition_count and rebuild when it grows.

Source

pub fn max_wait(self, max_wait: Duration) -> Self

How long a fetch waits at the broker for data before coming back empty.

Source

pub fn prefetch(self, prefetch: bool) -> Self

Keep a fetch permanently in flight, so the broker is already working while the caller processes the last batch. On by default.

Source

pub fn incremental_fetch(self, incremental: bool) -> Self

Incremental fetch sessions (KIP-227). On by default; turn it off for a broker or proxy that mishandles them.

Source

pub async fn build(self) -> Result<Consumer<T>>

Connect, authenticate, and resolve every assignment’s starting offset.

§Errors

If no bootstrap address answers, authentication fails, or a topic or partition in an assignment does not exist.

Auto Trait Implementations§

§

impl<T> Freeze for ConsumerReady<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ConsumerReady<T>
where T: RefUnwindSafe,

§

impl<T> Send for ConsumerReady<T>
where T: Send,

§

impl<T> Sync for ConsumerReady<T>
where T: Sync,

§

impl<T> Unpin for ConsumerReady<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ConsumerReady<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for ConsumerReady<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.