pub struct KafkaConfig {
pub url: String,
pub topic: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub tls: TlsConfig,
pub group_id: Option<String>,
pub delayed_ack: bool,
pub producer_options: Option<Vec<(String, String)>>,
pub consumer_options: Option<Vec<(String, String)>>,
}Expand description
General Kafka connection configuration.
Fields§
§url: StringComma-separated list of Kafka broker URLs. If it contains userinfo, it will be treated as a secret.
topic: Option<String>The Kafka topic to produce to or consume from.
username: Option<String>Optional username for SASL authentication.
password: Option<String>Optional password for SASL authentication.
tls: TlsConfigTLS configuration.
group_id: Option<String>(Consumer only) Consumer group ID. If not provided, the consumer acts in Subscriber mode: it generates a unique, ephemeral group ID and starts consuming from the latest offset.
delayed_ack: bool(Publisher only) If true, do not wait for an acknowledgement when sending to broker. Defaults to false.
producer_options: Option<Vec<(String, String)>>(Publisher only) Additional librdkafka producer configuration options (key-value pairs).
consumer_options: Option<Vec<(String, String)>>(Consumer only) Additional librdkafka consumer configuration options (key-value pairs).
Implementations§
Source§impl KafkaConfig
impl KafkaConfig
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Creates a new Kafka configuration with the specified broker URL.
pub fn with_topic(self, topic: impl Into<String>) -> Self
pub fn with_group_id(self, group_id: impl Into<String>) -> Self
pub fn with_credentials( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
pub fn with_producer_option( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
pub fn with_consumer_option( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Trait Implementations§
Source§impl Clone for KafkaConfig
impl Clone for KafkaConfig
Source§fn clone(&self) -> KafkaConfig
fn clone(&self) -> KafkaConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more