pub struct KafkaSinkConfig {Show 22 fields
pub bootstrap_servers: Vec<String>,
pub topic: String,
pub acks: String,
pub retries: u32,
pub max_in_flight_requests: usize,
pub enable_idempotence: bool,
pub request_timeout: Duration,
pub batch_size: usize,
pub linger: Duration,
pub buffer_memory: usize,
pub max_block: Duration,
pub compression: CompressionType,
pub max_request_size: usize,
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 socket_send_buffer_bytes: usize,
pub queued_max_messages: usize,
pub partitioner: Option<String>,
pub additional_properties: HashMap<String, String>,
}Expand description
Kafka sink (producer) configuration.
This structure provides all necessary settings for producing to Kafka topics, including delivery guarantees, batching, compression, and performance tuning.
§Examples
use processor::kafka::config::{KafkaSinkConfig, CompressionType};
use std::time::Duration;
let config = KafkaSinkConfig::builder()
.bootstrap_servers(vec!["localhost:9092".to_string()])
.topic("processed-events".to_string())
.compression(CompressionType::Lz4)
.batch_size(16384)
.linger(Duration::from_millis(10))
.acks("all".to_string())
.max_in_flight_requests(5)
.enable_idempotence(true)
.build()
.expect("valid configuration");
assert!(config.validate().is_ok());Fields§
§bootstrap_servers: Vec<String>Kafka broker addresses (host:port).
topic: StringDefault topic to produce to.
acks: StringNumber of acknowledgments required: “0”, “1”, or “all”.
retries: u32Number of retries for transient errors.
max_in_flight_requests: usizeMaximum in-flight requests per connection.
enable_idempotence: boolEnable idempotent producer.
request_timeout: DurationRequest timeout.
batch_size: usizeBatch size in bytes.
linger: DurationTime to wait before sending a batch (even if not full).
buffer_memory: usizeTotal memory buffer for producer.
max_block: DurationMaximum time to block on send.
compression: CompressionTypeCompression type for messages.
max_request_size: usizeMaximum size of a single message.
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.
socket_send_buffer_bytes: usizeSocket send buffer size.
queued_max_messages: usizeSize of the internal queue for buffering messages.
partitioner: Option<String>Custom partitioner class (rdkafka specific).
additional_properties: HashMap<String, String>Additional rdkafka configuration properties.
Implementations§
Source§impl KafkaSinkConfig
impl KafkaSinkConfig
Sourcepub fn builder() -> KafkaSinkConfigBuilder
pub fn builder() -> KafkaSinkConfigBuilder
Create a new builder for KafkaSinkConfig.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate the configuration.
§Errors
Returns an error if:
- Bootstrap servers are empty
- Topic is empty
- Invalid acks 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 KafkaSinkConfig
impl Clone for KafkaSinkConfig
Source§impl Debug for KafkaSinkConfig
impl Debug for KafkaSinkConfig
Source§impl<'de> Deserialize<'de> for KafkaSinkConfig
impl<'de> Deserialize<'de> for KafkaSinkConfig
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 KafkaSinkConfig
impl RefUnwindSafe for KafkaSinkConfig
impl Send for KafkaSinkConfig
impl Sync for KafkaSinkConfig
impl Unpin for KafkaSinkConfig
impl UnsafeUnpin for KafkaSinkConfig
impl UnwindSafe for KafkaSinkConfig
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.