Skip to main content

ProducerConfig

Struct ProducerConfig 

Source
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

Source

pub const BOOTSTRAP_SERVERS_CONFIG: &'static str = "bootstrap.servers"

Config key: bootstrap.servers

Source

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.

Source

pub const CLIENT_ID_CONFIG: &'static str = "client.id"

Config key: client.id

Source

pub const CLIENT_RACK_CONFIG: &'static str = CommonClientConfigs::CLIENT_RACK_CONFIG

Config key: client.rack

Source

pub const DEFAULT_CLIENT_RACK: &'static str = CommonClientConfigs::DEFAULT_CLIENT_RACK

Default value of client.rack: no rack.

Source

pub const BATCH_SIZE_CONFIG: &'static str = "batch.size"

Config key: batch.size

Source

pub const LINGER_MS_CONFIG: &'static str = "linger.ms"

Config key: linger.ms

Source

pub const BUFFER_MEMORY_CONFIG: &'static str = "buffer.memory"

Config key: buffer.memory

Source

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.

Source

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).

Source

pub const BUFFER_MEMORY_ALLOCATION_STRATEGY_INCREMENTAL: &'static str = "incremental"

buffer.memory.allocation.strategy value: allocate memory on demand as records are appended.

Source

pub const MAX_BLOCK_MS_CONFIG: &'static str = "max.block.ms"

Config key: max.block.ms

Source

pub const ACKS_CONFIG: &'static str = "acks"

Config key: acks

Source

pub const RETRIES_CONFIG: &'static str = "retries"

Config key: retries

Source

pub const DELIVERY_TIMEOUT_MS_CONFIG: &'static str = "delivery.timeout.ms"

Config key: delivery.timeout.ms

Source

pub const REQUEST_TIMEOUT_MS_CONFIG: &'static str = "request.timeout.ms"

Config key: request.timeout.ms

Source

pub const ENABLE_IDEMPOTENCE_CONFIG: &'static str = "enable.idempotence"

Config key: enable.idempotence

Source

pub const MAX_REQUEST_SIZE_CONFIG: &'static str = "max.request.size"

Config key: max.request.size

Source

pub const MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION: &'static str = "max.in.flight.requests.per.connection"

Config key: max.in.flight.requests.per.connection

Source

pub const COMPRESSION_TYPE_CONFIG: &'static str = "compression.type"

Config key: compression.type

Source

pub const CONNECTIONS_MAX_IDLE_MS_CONFIG: &'static str = "connections.max.idle.ms"

Config key: connections.max.idle.ms

Source

pub const RECONNECT_BACKOFF_MS_CONFIG: &'static str = "reconnect.backoff.ms"

Config key: reconnect.backoff.ms

Source

pub const RECONNECT_BACKOFF_MAX_MS_CONFIG: &'static str = "reconnect.backoff.max.ms"

Config key: reconnect.backoff.max.ms

Source

pub const RETRY_BACKOFF_MS_CONFIG: &'static str = "retry.backoff.ms"

Config key: retry.backoff.ms

Source

pub const RETRY_BACKOFF_MAX_MS_CONFIG: &'static str = "retry.backoff.max.ms"

Config key: retry.backoff.max.ms

Source

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.

Source

pub const SEND_BUFFER_CONFIG: &'static str = "send.buffer.bytes"

Config key: send.buffer.bytes

Source

pub const RECEIVE_BUFFER_CONFIG: &'static str = "receive.buffer.bytes"

Config key: receive.buffer.bytes

Source

pub const METADATA_MAX_AGE_CONFIG: &'static str = "metadata.max.age.ms"

Config key: metadata.max.age.ms

Source

pub const METADATA_MAX_IDLE_CONFIG: &'static str = "metadata.max.idle.ms"

Config key: metadata.max.idle.ms

Source

pub const PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_CONFIG: &'static str = "partitioner.adaptive.partitioning.enable"

Config key: partitioner.adaptive.partitioning.enable

Source

pub const PARTITIONER_AVAILABILITY_TIMEOUT_MS_CONFIG: &'static str = "partitioner.availability.timeout.ms"

Config key: partitioner.availability.timeout.ms

Source

pub const PARTITIONER_IGNORE_KEYS_CONFIG: &'static str = "partitioner.ignore.keys"

Config key: partitioner.ignore.keys

Source

pub const PARTITIONER_RACK_AWARE_CONFIG: &'static str = "partitioner.rack.aware"

Config key: partitioner.rack.aware

Source

pub const PARTITIONER_TYPE_CONFIG: &'static str = "partitioner.type"

Config key: partitioner.type

Source

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.

Source

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.

Source

pub const ROUND_ROBIN_PARTITIONER: &'static str = "RoundRobinPartitioner"

Accepted partitioner.type value selecting the RoundRobinPartitioner.

Source

pub const TRANSACTIONAL_ID_CONFIG: &'static str = "transactional.id"

Config key: transactional.id

Source

pub const TRANSACTION_TIMEOUT_CONFIG: &'static str = "transaction.timeout.ms"

Config key: transaction.timeout.ms

Source

pub const METRICS_SAMPLE_WINDOW_MS_CONFIG: &'static str = "metrics.sample.window.ms"

Config key: metrics.sample.window.ms

Source

pub const METRICS_NUM_SAMPLES_CONFIG: &'static str = "metrics.num.samples"

Config key: metrics.num.samples

Source

pub const METRICS_RECORDING_LEVEL_CONFIG: &'static str = "metrics.recording.level"

Config key: metrics.recording.level

Source

pub const TRANSACTION_TWO_PHASE_COMMIT_ENABLE_CONFIG: &'static str = "transaction.two.phase.commit.enable"

Config key: transaction.two.phase.commit.enable

Source

pub const COMPRESSION_GZIP_LEVEL_CONFIG: &'static str = "compression.gzip.level"

Config key: compression.gzip.level

Source

pub const COMPRESSION_LZ4_LEVEL_CONFIG: &'static str = "compression.lz4.level"

Config key: compression.lz4.level

Source

pub const COMPRESSION_ZSTD_LEVEL_CONFIG: &'static str = "compression.zstd.level"

Config key: compression.zstd.level

Source

pub const SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG: &'static str = "socket.connection.setup.timeout.ms"

Config key: socket.connection.setup.timeout.ms

Source

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

Source

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_error if a value is invalid, the settings conflict, or sasl.mechanism is not PLAIN under a SASL security.protocol.
§Translation notes

WARNING: sasl.mechanism must be PLAIN.

Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

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.

Source

pub fn ignore(&self, key: &str)

Marks the configuration key used without reading it.

§Arguments
  • key - the configuration name
Source

pub fn log_unused(&self)

Info level log for any unused configurations

Source

pub fn config_names() -> HashSet<String>

The names of the configurations this class defines.

§Returns

The set of configuration names

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ProducerConfig

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ProducerConfig

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ProducerConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V