pub struct KafkaConsumerOptions { /* private fields */ }

Implementations§

source§

impl KafkaConsumerOptions

source

pub fn set_group_id(&mut self, id: ConsumerGroup) -> &mut Self

A unique string that identifies the consumer group this consumer belongs to. This property is required if the consumer uses either the group management functionality by using subscribe(topic) or the Kafka-based offset management strategy.

https://kafka.apache.org/documentation/#connectconfigs_group.id

source

pub fn group_id(&self) -> Option<&ConsumerGroup>

source

pub fn set_session_timeout(&mut self, v: Duration) -> &mut Self

The timeout used to detect worker failures. The worker sends periodic heartbeats to indicate its liveness to the broker. If no heartbeats are received by the broker before the expiration of this session timeout, then the broker will remove the worker from the group and initiate a rebalance.

https://kafka.apache.org/documentation/#connectconfigs_session.timeout.ms

source

pub fn session_timeout(&self) -> Option<&Duration>

source

pub fn set_auto_offset_reset(&mut self, v: AutoOffsetReset) -> &mut Self

Where to stream from when there is no initial offset in Kafka or if the current offset does not exist any more on the server.

If unset, defaults to Latest.

https://kafka.apache.org/documentation/#consumerconfigs_auto.offset.reset

source

pub fn auto_offset_reset(&self) -> Option<&AutoOffsetReset>

source

pub fn set_enable_auto_commit(&mut self, v: bool) -> &mut Self

If enabled, the consumer’s offset will be periodically committed in the background.

If unset, defaults to true.

https://kafka.apache.org/documentation/#consumerconfigs_enable.auto.commit

source

pub fn enable_auto_commit(&self) -> Option<&bool>

source

pub fn set_auto_commit_interval(&mut self, v: Duration) -> &mut Self

The interval for offsets to be auto-committed. If enable_auto_commit is set to false, this will have no effect.

https://kafka.apache.org/documentation/#consumerconfigs_auto.commit.interval.ms

source

pub fn auto_commit_interval(&self) -> Option<&Duration>

source

pub fn set_enable_auto_offset_store(&mut self, v: bool) -> &mut Self

If enabled, the consumer’s offset will be updated as the messages are read. This does not equate to them being processed. So if you want to make sure to commit only what have been processed, set it to false. You will have to manually update these offsets.

If unset, defaults to true.

source

pub fn enable_auto_offset_store(&self) -> Option<&bool>

source

pub fn add_custom_option<K, V>(&mut self, key: K, value: V) -> &mut Selfwhere K: Into<String>, V: Into<String>,

Add a custom option. If you have an option you frequently use, please consider open a PR and add it to above.

source

pub fn custom_options(&self) -> impl Iterator<Item = (&str, &str)>

Trait Implementations§

source§

impl Clone for KafkaConsumerOptions

source§

fn clone(&self) -> KafkaConsumerOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl ConsumerOptions for KafkaConsumerOptions

source§

fn set_consumer_group(&mut self, group: ConsumerGroup) -> KafkaResult<&mut Self>

If multiple consumers shares the same group, only one consumer in the group will receive a message, i.e. it is load-balanced.

However, the load-balancing mechanism is what makes Kafka different:

Each stream is divided into multiple shards (known as partition), and each partition will be assigned to only one consumer in a group.

Say there are 2 consumers (in the group) and 2 partitions, then each consumer will receive messages from one partition, and they are thus load-balanced.

If there are 2 consumers and 3 partitions, then one consumer will be assigned 2 partitions, and the other will be assigned only 1.

However if the stream has only 1 partition, even if there are many consumers, these messages will only be received by the assigned consumer, and other consumers will be in stand-by mode, resulting in a hot-failover setup.

§

type Error = KafkaError

source§

fn new(mode: ConsumerMode) -> Self

source§

fn mode(&self) -> KafkaResult<&ConsumerMode>

Get currently set ConsumerMode
source§

fn consumer_group(&self) -> KafkaResult<&ConsumerGroup>

Get currently set consumer group; may return StreamErr::ConsumerGroupNotSet.
source§

impl Debug for KafkaConsumerOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for KafkaConsumerOptions

source§

fn default() -> KafkaConsumerOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.