pub struct KafkaSourceConfig {Show 22 fields
pub bootstrap_servers: Vec<String>,
pub group_id: String,
pub topics: Vec<String>,
pub auto_offset_reset: String,
pub enable_auto_commit: bool,
pub auto_commit_interval: Duration,
pub max_poll_records: usize,
pub fetch_wait_max: Duration,
pub fetch_min_bytes: usize,
pub max_partition_fetch_bytes: usize,
pub session_timeout: Duration,
pub heartbeat_interval: Duration,
pub security_protocol: SecurityProtocol,
pub sasl_mechanism: Option<SaslMechanism>,
pub sasl_username: Option<String>,
pub sasl_password: Option<String>,
pub ssl_config: Option<SslConfig>,
pub num_consumer_threads: usize,
pub queued_max_messages: usize,
pub socket_receive_buffer_bytes: usize,
pub isolation_level: String,
pub additional_properties: HashMap<String, String>,
}Expand description
Kafka source (consumer) configuration.
This structure provides all necessary settings for consuming from Kafka topics, including consumer group management, offset handling, and performance tuning.
§Examples
use processor::kafka::config::{KafkaSourceConfig, SecurityProtocol};
use std::time::Duration;
let config = KafkaSourceConfig::builder()
.bootstrap_servers(vec!["localhost:9092".to_string()])
.group_id("my-consumer-group".to_string())
.topics(vec!["events".to_string(), "metrics".to_string()])
.auto_offset_reset("earliest".to_string())
.enable_auto_commit(false)
.max_poll_records(500)
.session_timeout(Duration::from_secs(30))
.build()
.expect("valid configuration");
assert!(config.validate().is_ok());Fields§
§bootstrap_servers: Vec<String>Kafka broker addresses (host:port).
group_id: StringConsumer group ID for coordinated consumption.
topics: Vec<String>Topics to subscribe to.
auto_offset_reset: StringWhat to do when there is no initial offset: “earliest”, “latest”, “none”.
enable_auto_commit: boolEnable automatic offset commits.
auto_commit_interval: DurationFrequency of auto-commits if enabled.
max_poll_records: usizeMaximum number of records to poll in a single batch.
fetch_wait_max: DurationMaximum time to wait for poll batch to fill.
fetch_min_bytes: usizeMinimum bytes to fetch per request.
max_partition_fetch_bytes: usizeMaximum bytes to fetch per partition.
session_timeout: DurationSession timeout for consumer group membership.
heartbeat_interval: DurationHeartbeat interval to coordinator.
security_protocol: SecurityProtocolSecurity protocol to use.
sasl_mechanism: Option<SaslMechanism>SASL mechanism if using SASL authentication.
sasl_username: Option<String>SASL username.
sasl_password: Option<String>SASL password.
ssl_config: Option<SslConfig>SSL configuration.
num_consumer_threads: usizeNumber of consumer threads for parallel consumption.
queued_max_messages: usizeSize of the internal queue for buffering messages.
socket_receive_buffer_bytes: usizeSocket receive buffer size.
isolation_level: StringTransaction isolation level: “read_uncommitted” or “read_committed”.
additional_properties: HashMap<String, String>Additional rdkafka configuration properties.
Implementations§
Source§impl KafkaSourceConfig
impl KafkaSourceConfig
Sourcepub fn builder() -> KafkaSourceConfigBuilder
pub fn builder() -> KafkaSourceConfigBuilder
Create a new builder for KafkaSourceConfig.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the configuration.
§Errors
Returns an error if:
- Bootstrap servers are empty
- Group ID is empty
- Topics are empty
- Invalid auto_offset_reset value
- Invalid isolation_level value
- SASL credentials missing when SASL is enabled
Sourcepub fn to_rdkafka_properties(&self) -> HashMap<String, String>
pub fn to_rdkafka_properties(&self) -> HashMap<String, String>
Convert to rdkafka ClientConfig properties.
Trait Implementations§
Source§impl Clone for KafkaSourceConfig
impl Clone for KafkaSourceConfig
Source§impl Debug for KafkaSourceConfig
impl Debug for KafkaSourceConfig
Source§impl<'de> Deserialize<'de> for KafkaSourceConfig
impl<'de> Deserialize<'de> for KafkaSourceConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for KafkaSourceConfig
impl RefUnwindSafe for KafkaSourceConfig
impl Send for KafkaSourceConfig
impl Sync for KafkaSourceConfig
impl Unpin for KafkaSourceConfig
impl UnsafeUnpin for KafkaSourceConfig
impl UnwindSafe for KafkaSourceConfig
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.