pub struct ProducerConfig { /* private fields */ }Expand description
Configuration for the Kafka Producer. Documentation for these configurations can be found in the Kafka documentation.
Implementations§
Source§impl ProducerConfig
impl ProducerConfig
Sourcepub const BOOTSTRAP_SERVERS_CONFIG: &'static str = "bootstrap.servers"
pub const BOOTSTRAP_SERVERS_CONFIG: &'static str = "bootstrap.servers"
Config key: bootstrap.servers
Sourcepub const CLIENT_DNS_LOOKUP_CONFIG: &'static str = CommonClientConfigs::CLIENT_DNS_LOOKUP_CONFIG
pub const CLIENT_DNS_LOOKUP_CONFIG: &'static str = CommonClientConfigs::CLIENT_DNS_LOOKUP_CONFIG
Config key: client.dns.lookup. Java’s ProducerConfig.java declares it as its
own public alias of CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG.
Sourcepub const CLIENT_ID_CONFIG: &'static str = "client.id"
pub const CLIENT_ID_CONFIG: &'static str = "client.id"
Config key: client.id
Sourcepub const CLIENT_RACK_CONFIG: &'static str = CommonClientConfigs::CLIENT_RACK_CONFIG
pub const CLIENT_RACK_CONFIG: &'static str = CommonClientConfigs::CLIENT_RACK_CONFIG
Config key: client.rack
Sourcepub const DEFAULT_CLIENT_RACK: &'static str = CommonClientConfigs::DEFAULT_CLIENT_RACK
pub const DEFAULT_CLIENT_RACK: &'static str = CommonClientConfigs::DEFAULT_CLIENT_RACK
Default value of client.rack: no rack.
Sourcepub const BATCH_SIZE_CONFIG: &'static str = "batch.size"
pub const BATCH_SIZE_CONFIG: &'static str = "batch.size"
Config key: batch.size
Sourcepub const LINGER_MS_CONFIG: &'static str = "linger.ms"
pub const LINGER_MS_CONFIG: &'static str = "linger.ms"
Config key: linger.ms
Sourcepub const BUFFER_MEMORY_CONFIG: &'static str = "buffer.memory"
pub const BUFFER_MEMORY_CONFIG: &'static str = "buffer.memory"
Config key: buffer.memory
Sourcepub const BUFFER_MEMORY_ALLOCATION_STRATEGY_CONFIG: &'static str = "buffer.memory.allocation.strategy"
pub const BUFFER_MEMORY_ALLOCATION_STRATEGY_CONFIG: &'static str = "buffer.memory.allocation.strategy"
Config key: buffer.memory.allocation.strategy (KIP-1332). Internal until the incremental
strategy is fully implemented.
Sourcepub const BUFFER_MEMORY_ALLOCATION_STRATEGY_FULL: &'static str = "full"
pub const BUFFER_MEMORY_ALLOCATION_STRATEGY_FULL: &'static str = "full"
buffer.memory.allocation.strategy value: reserve a full batch.size per batch up front
(the default).
Sourcepub const BUFFER_MEMORY_ALLOCATION_STRATEGY_INCREMENTAL: &'static str = "incremental"
pub const BUFFER_MEMORY_ALLOCATION_STRATEGY_INCREMENTAL: &'static str = "incremental"
buffer.memory.allocation.strategy value: allocate memory on demand as records are
appended.
Sourcepub const MAX_BLOCK_MS_CONFIG: &'static str = "max.block.ms"
pub const MAX_BLOCK_MS_CONFIG: &'static str = "max.block.ms"
Config key: max.block.ms
Sourcepub const ACKS_CONFIG: &'static str = "acks"
pub const ACKS_CONFIG: &'static str = "acks"
Config key: acks
Sourcepub const RETRIES_CONFIG: &'static str = "retries"
pub const RETRIES_CONFIG: &'static str = "retries"
Config key: retries
Sourcepub const DELIVERY_TIMEOUT_MS_CONFIG: &'static str = "delivery.timeout.ms"
pub const DELIVERY_TIMEOUT_MS_CONFIG: &'static str = "delivery.timeout.ms"
Config key: delivery.timeout.ms
Sourcepub const REQUEST_TIMEOUT_MS_CONFIG: &'static str = "request.timeout.ms"
pub const REQUEST_TIMEOUT_MS_CONFIG: &'static str = "request.timeout.ms"
Config key: request.timeout.ms
Sourcepub const ENABLE_IDEMPOTENCE_CONFIG: &'static str = "enable.idempotence"
pub const ENABLE_IDEMPOTENCE_CONFIG: &'static str = "enable.idempotence"
Config key: enable.idempotence
Sourcepub const MAX_REQUEST_SIZE_CONFIG: &'static str = "max.request.size"
pub const MAX_REQUEST_SIZE_CONFIG: &'static str = "max.request.size"
Config key: max.request.size
Sourcepub const MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION: &'static str = "max.in.flight.requests.per.connection"
pub const MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION: &'static str = "max.in.flight.requests.per.connection"
Config key: max.in.flight.requests.per.connection
Sourcepub const COMPRESSION_TYPE_CONFIG: &'static str = "compression.type"
pub const COMPRESSION_TYPE_CONFIG: &'static str = "compression.type"
Config key: compression.type
Sourcepub const CONNECTIONS_MAX_IDLE_MS_CONFIG: &'static str = "connections.max.idle.ms"
pub const CONNECTIONS_MAX_IDLE_MS_CONFIG: &'static str = "connections.max.idle.ms"
Config key: connections.max.idle.ms
Sourcepub const RECONNECT_BACKOFF_MS_CONFIG: &'static str = "reconnect.backoff.ms"
pub const RECONNECT_BACKOFF_MS_CONFIG: &'static str = "reconnect.backoff.ms"
Config key: reconnect.backoff.ms
Sourcepub const RECONNECT_BACKOFF_MAX_MS_CONFIG: &'static str = "reconnect.backoff.max.ms"
pub const RECONNECT_BACKOFF_MAX_MS_CONFIG: &'static str = "reconnect.backoff.max.ms"
Config key: reconnect.backoff.max.ms
Sourcepub const RETRY_BACKOFF_MS_CONFIG: &'static str = "retry.backoff.ms"
pub const RETRY_BACKOFF_MS_CONFIG: &'static str = "retry.backoff.ms"
Config key: retry.backoff.ms
Sourcepub const RETRY_BACKOFF_MAX_MS_CONFIG: &'static str = "retry.backoff.max.ms"
pub const RETRY_BACKOFF_MAX_MS_CONFIG: &'static str = "retry.backoff.max.ms"
Config key: retry.backoff.max.ms
Sourcepub const BOOTSTRAP_RESOLVE_TIMEOUT_MS_CONFIG: &'static str = CommonClientConfigs::BOOTSTRAP_RESOLVE_TIMEOUT_MS_CONFIG
pub const BOOTSTRAP_RESOLVE_TIMEOUT_MS_CONFIG: &'static str = CommonClientConfigs::BOOTSTRAP_RESOLVE_TIMEOUT_MS_CONFIG
Config key: bootstrap.resolve.timeout.ms (KIP-909)
Selects the client’s bootstrap DNS resolution mode. When set to 0 (the
default), DNS is resolved synchronously during client construction; any
failure surfaces as a config error and no client instance is created.
When set to a positive value, DNS is resolved asynchronously and this is
the maximum amount of time the client will spend retrying resolution
before failing with an unrecoverable
BootstrapResolutionError
from subsequent API calls (the client must then be closed and re-created
after fixing the underlying DNS or bootstrap.servers configuration
issue). Setting this config to a positive value enables an evolving
feature whose compatibility may be broken in a minor release.
Sourcepub const SEND_BUFFER_CONFIG: &'static str = "send.buffer.bytes"
pub const SEND_BUFFER_CONFIG: &'static str = "send.buffer.bytes"
Config key: send.buffer.bytes
Sourcepub const RECEIVE_BUFFER_CONFIG: &'static str = "receive.buffer.bytes"
pub const RECEIVE_BUFFER_CONFIG: &'static str = "receive.buffer.bytes"
Config key: receive.buffer.bytes
Sourcepub const METADATA_MAX_AGE_CONFIG: &'static str = "metadata.max.age.ms"
pub const METADATA_MAX_AGE_CONFIG: &'static str = "metadata.max.age.ms"
Config key: metadata.max.age.ms
Sourcepub const METADATA_MAX_IDLE_CONFIG: &'static str = "metadata.max.idle.ms"
pub const METADATA_MAX_IDLE_CONFIG: &'static str = "metadata.max.idle.ms"
Config key: metadata.max.idle.ms
Sourcepub const PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_CONFIG: &'static str = "partitioner.adaptive.partitioning.enable"
pub const PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_CONFIG: &'static str = "partitioner.adaptive.partitioning.enable"
Config key: partitioner.adaptive.partitioning.enable
Sourcepub const PARTITIONER_AVAILABILITY_TIMEOUT_MS_CONFIG: &'static str = "partitioner.availability.timeout.ms"
pub const PARTITIONER_AVAILABILITY_TIMEOUT_MS_CONFIG: &'static str = "partitioner.availability.timeout.ms"
Config key: partitioner.availability.timeout.ms
Sourcepub const PARTITIONER_IGNORE_KEYS_CONFIG: &'static str = "partitioner.ignore.keys"
pub const PARTITIONER_IGNORE_KEYS_CONFIG: &'static str = "partitioner.ignore.keys"
Config key: partitioner.ignore.keys
Sourcepub const PARTITIONER_RACK_AWARE_CONFIG: &'static str = "partitioner.rack.aware"
pub const PARTITIONER_RACK_AWARE_CONFIG: &'static str = "partitioner.rack.aware"
Config key: partitioner.rack.aware
Sourcepub const PARTITIONER_TYPE_CONFIG: &'static str = "partitioner.type"
pub const PARTITIONER_TYPE_CONFIG: &'static str = "partitioner.type"
Config key: partitioner.type
Sourcepub const CONSISTENT_RANDOM_PARTITIONER: &'static str = "ConsistentRandomPartitioner"
pub const CONSISTENT_RANDOM_PARTITIONER: &'static str = "ConsistentRandomPartitioner"
Accepted partitioner.type value selecting the CRC-32 key hash
(the crate-internal KeyHasher::Crc32) — the default, librdkafka consistent_random parity.
Sourcepub const MURMUR2_RANDOM_PARTITIONER: &'static str = "Murmur2RandomPartitioner"
pub const MURMUR2_RANDOM_PARTITIONER: &'static str = "Murmur2RandomPartitioner"
Accepted partitioner.type value selecting the murmur2 key hash
(the crate-internal KeyHasher::Murmur2) — exact Java-client parity.
Sourcepub const ROUND_ROBIN_PARTITIONER: &'static str = "RoundRobinPartitioner"
pub const ROUND_ROBIN_PARTITIONER: &'static str = "RoundRobinPartitioner"
Accepted partitioner.type value selecting the
RoundRobinPartitioner.
Sourcepub const TRANSACTIONAL_ID_CONFIG: &'static str = "transactional.id"
pub const TRANSACTIONAL_ID_CONFIG: &'static str = "transactional.id"
Config key: transactional.id
Sourcepub const TRANSACTION_TIMEOUT_CONFIG: &'static str = "transaction.timeout.ms"
pub const TRANSACTION_TIMEOUT_CONFIG: &'static str = "transaction.timeout.ms"
Config key: transaction.timeout.ms
Sourcepub const METRICS_SAMPLE_WINDOW_MS_CONFIG: &'static str = "metrics.sample.window.ms"
pub const METRICS_SAMPLE_WINDOW_MS_CONFIG: &'static str = "metrics.sample.window.ms"
Config key: metrics.sample.window.ms
Sourcepub const METRICS_NUM_SAMPLES_CONFIG: &'static str = "metrics.num.samples"
pub const METRICS_NUM_SAMPLES_CONFIG: &'static str = "metrics.num.samples"
Config key: metrics.num.samples
Sourcepub const METRICS_RECORDING_LEVEL_CONFIG: &'static str = "metrics.recording.level"
pub const METRICS_RECORDING_LEVEL_CONFIG: &'static str = "metrics.recording.level"
Config key: metrics.recording.level
Sourcepub const TRANSACTION_TWO_PHASE_COMMIT_ENABLE_CONFIG: &'static str = "transaction.two.phase.commit.enable"
pub const TRANSACTION_TWO_PHASE_COMMIT_ENABLE_CONFIG: &'static str = "transaction.two.phase.commit.enable"
Config key: transaction.two.phase.commit.enable
Sourcepub const COMPRESSION_GZIP_LEVEL_CONFIG: &'static str = "compression.gzip.level"
pub const COMPRESSION_GZIP_LEVEL_CONFIG: &'static str = "compression.gzip.level"
Config key: compression.gzip.level
Sourcepub const COMPRESSION_LZ4_LEVEL_CONFIG: &'static str = "compression.lz4.level"
pub const COMPRESSION_LZ4_LEVEL_CONFIG: &'static str = "compression.lz4.level"
Config key: compression.lz4.level
Sourcepub const COMPRESSION_ZSTD_LEVEL_CONFIG: &'static str = "compression.zstd.level"
pub const COMPRESSION_ZSTD_LEVEL_CONFIG: &'static str = "compression.zstd.level"
Config key: compression.zstd.level
Sourcepub const SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG: &'static str = "socket.connection.setup.timeout.ms"
pub const SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG: &'static str = "socket.connection.setup.timeout.ms"
Config key: socket.connection.setup.timeout.ms
Sourcepub const SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG: &'static str = "socket.connection.setup.timeout.max.ms"
pub const SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG: &'static str = "socket.connection.setup.timeout.max.ms"
Config key: socket.connection.setup.timeout.max.ms
Sourcepub fn new(props: &HashMap<String, String>) -> Result<Self, Error>
pub fn new(props: &HashMap<String, String>) -> Result<Self, Error>
Constructs a new ProducerConfig with the given configuration map.
§Arguments
props- The producer configuration map
§Errors
Error::is_config_errorif a value is invalid, the settings conflict, orsasl.mechanismis notPLAINunder a SASLsecurity.protocol.
§Translation notes
WARNING: sasl.mechanism must be PLAIN.
Sourcepub fn get_short(&self, key: &str) -> Result<Option<i16>, Error>
pub fn get_short(&self, key: &str) -> Result<Option<i16>, Error>
The SHORT configuration key. Reading a key marks it used
(Self::unused).
§Arguments
key- the configuration name
§Returns
The value, None for Java’s null.
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn get_int(&self, key: &str) -> Result<Option<i32>, Error>
pub fn get_int(&self, key: &str) -> Result<Option<i32>, Error>
The INT configuration key. Reading a key marks it used
(Self::unused).
§Arguments
key- the configuration name
§Returns
The value, None for Java’s null.
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn get_long(&self, key: &str) -> Result<Option<i64>, Error>
pub fn get_long(&self, key: &str) -> Result<Option<i64>, Error>
The LONG configuration key. Reading a key marks it used
(Self::unused).
§Arguments
key- the configuration name
§Returns
The value, None for Java’s null.
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn get_double(&self, key: &str) -> Result<Option<f64>, Error>
pub fn get_double(&self, key: &str) -> Result<Option<f64>, Error>
The DOUBLE configuration key. Reading a key marks it used
(Self::unused).
§Arguments
key- the configuration name
§Returns
The value, None for Java’s null.
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn get_list(&self, key: &str) -> Result<Option<&[String]>, Error>
pub fn get_list(&self, key: &str) -> Result<Option<&[String]>, Error>
The LIST configuration key. Reading a key marks it used
(Self::unused).
§Arguments
key- the configuration name
§Returns
The value, borrowed from the parsed values, None for Java’s null.
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn get_boolean(&self, key: &str) -> Result<Option<bool>, Error>
pub fn get_boolean(&self, key: &str) -> Result<Option<bool>, Error>
The BOOLEAN configuration key. Reading a key marks it used
(Self::unused).
enable.idempotence answers the value postProcessParsedConfig
settled on: false when an incompatible retries or acks disabled
it.
§Arguments
key- the configuration name
§Returns
The value, None for Java’s null.
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn get_string(&self, key: &str) -> Result<Option<&str>, Error>
pub fn get_string(&self, key: &str) -> Result<Option<&str>, Error>
The STRING configuration key. Reading a key marks it used
(Self::unused).
client.id answers the resolved id: when the property is unset, new
derives it the way Java’s maybeOverrideClientId does, so this is the
id the producer reports to the brokers. acks answers the number
Java’s parseAcks settled on ("-1" for all). security.protocol
answers the value as written, trimmed ("sasl_ssl"), as Java’s does:
its validator accepts it case-insensitively without changing it. A
PASSWORD configuration that is not set answers None, as Java’s
null default casts to String (SslConfigs, SaslConfigs).
§Arguments
key- the configuration name
§Returns
The value, trimmed, or None when it has no value (Java’s null,
e.g. an unset transactional.id).
§Errors
Error::is_config_errorwith Java’sUnknown configuration '<key>'ifkeyis not a configuration this class defines.Error::is_local_illegal_argument_errorifkeyis a configuration of another type, where Java’s cast fails with aClassCastException.
Sourcepub fn unused(&self) -> HashSet<String>
pub fn unused(&self) -> HashSet<String>
Returns the keys of the properties this configuration was built from that were never read: through a getter, or by the producer built from it.
Sourcepub fn log_unused(&self)
pub fn log_unused(&self)
Info level log for any unused configurations
Sourcepub fn config_names() -> HashSet<String>
pub fn config_names() -> HashSet<String>
Sourcepub fn set_partitioner<K: 'static, V: 'static>(
self,
partitioner: Box<dyn Partitioner<K, V>>,
) -> Self
pub fn set_partitioner<K: 'static, V: 'static>( self, partitioner: Box<dyn Partitioner<K, V>>, ) -> Self
Sets the Partitioner that determines which partition each record
goes to: the value of Java’s partitioner.class.
Java names a class, which the producer instantiates by reflection; here
the partitioner itself is the value. KafkaProducer::new
configures it with the user configs plus the resolved client.id, as
Java does (KafkaProducer#KafkaProducer), and closes it on close. As
with any configured partitioner, adaptive partitioning is then disabled.
The producer built from this config takes ownership of the partitioner.
This replaces a partitioner.type given in the properties passed to
new, as a later value for the same key would.
The partitioner’s K / V must be the record types of the producer built
from this config; otherwise KafkaProducer::new fails with
“<partitioner> is not an instance of <expected>”.
§Arguments
partitioner- the partitioner the producer uses
§Returns
This configuration, with the partitioner set.
Trait Implementations§
Source§impl Debug for ProducerConfig
impl Debug for ProducerConfig
Source§impl Hash for ProducerConfig
impl Hash for ProducerConfig
Source§impl PartialEq for ProducerConfig
impl PartialEq for ProducerConfig
impl Eq for ProducerConfig
Auto Trait Implementations§
impl !Freeze for ProducerConfig
impl !RefUnwindSafe for ProducerConfig
impl Send for ProducerConfig
impl Sync for ProducerConfig
impl Unpin for ProducerConfig
impl UnsafeUnpin for ProducerConfig
impl !UnwindSafe for ProducerConfig
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.