Struct sea_streamer_kafka::KafkaConsumerOptions
source · pub struct KafkaConsumerOptions { /* private fields */ }
Implementations§
source§impl KafkaConsumerOptions
impl KafkaConsumerOptions
sourcepub fn set_group_id(&mut self, id: ConsumerGroup) -> &mut Self
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
pub fn group_id(&self) -> Option<&ConsumerGroup>
sourcepub fn set_session_timeout(&mut self, v: Duration) -> &mut Self
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
pub fn session_timeout(&self) -> Option<&Duration>
sourcepub fn set_auto_offset_reset(&mut self, v: AutoOffsetReset) -> &mut Self
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
pub fn auto_offset_reset(&self) -> Option<&AutoOffsetReset>
sourcepub fn set_enable_auto_commit(&mut self, v: bool) -> &mut Self
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
pub fn enable_auto_commit(&self) -> Option<&bool>
sourcepub fn set_auto_commit_interval(&mut self, v: Duration) -> &mut Self
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
pub fn auto_commit_interval(&self) -> Option<&Duration>
sourcepub fn set_enable_auto_offset_store(&mut self, v: bool) -> &mut Self
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.
pub fn enable_auto_offset_store(&self) -> Option<&bool>
sourcepub fn add_custom_option<K, V>(&mut self, key: K, value: V) -> &mut Selfwhere
K: Into<String>,
V: Into<String>,
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.
pub fn custom_options(&self) -> impl Iterator<Item = (&str, &str)>
Trait Implementations§
source§impl Clone for KafkaConsumerOptions
impl Clone for KafkaConsumerOptions
source§fn clone(&self) -> KafkaConsumerOptions
fn clone(&self) -> KafkaConsumerOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl ConsumerOptions for KafkaConsumerOptions
impl ConsumerOptions for KafkaConsumerOptions
source§fn set_consumer_group(&mut self, group: ConsumerGroup) -> KafkaResult<&mut Self>
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
fn new(mode: ConsumerMode) -> Self
source§fn mode(&self) -> KafkaResult<&ConsumerMode>
fn mode(&self) -> KafkaResult<&ConsumerMode>
source§fn consumer_group(&self) -> KafkaResult<&ConsumerGroup>
fn consumer_group(&self) -> KafkaResult<&ConsumerGroup>
StreamErr::ConsumerGroupNotSet
.