|
|
@@ -13,19 +13,22 @@ func forceFlushThreshold() int {
|
|
|
}
|
|
|
|
|
|
// ProducerConfig is used to pass multiple configuration options to NewProducer.
|
|
|
+//
|
|
|
+// Some of these configuration settings match settings with the JVM producer, but some of
|
|
|
+// these are implementation specific and have no equivalent in the JVM producer.
|
|
|
type ProducerConfig struct {
|
|
|
- Partitioner PartitionerConstructor // Generates partitioners for choosing the partition to send messages to (defaults to hash).
|
|
|
- RequiredAcks RequiredAcks // The level of acknowledgement reliability needed from the broker (defaults to WaitForLocal).
|
|
|
- Timeout time.Duration // The maximum duration the broker will wait the receipt of the number of RequiredAcks. This is only relevant when RequiredAcks is set to WaitForAll or a number > 1. Only supports millisecond resolution, nanoseconds will be truncated.
|
|
|
- Compression CompressionCodec // The type of compression to use on messages (defaults to no compression).
|
|
|
- FlushMsgCount int // The number of messages needed to trigger a flush. This is a minimum, not an upper limit (use MaxMessagesPerReq for that).
|
|
|
- FlushFrequency time.Duration // If this amount of time elapses without a flush, one will be queued. This is a minimum, not an upper limit.
|
|
|
- FlushByteCount int // If this many bytes of messages are accumulated, a flush will be triggered. This is a minimum, not an upper limit.
|
|
|
+ Partitioner PartitionerConstructor // Generates partitioners for choosing the partition to send messages to (defaults to hash). Similar to the `partitioner.class` setting for the JVM producer.
|
|
|
+ RequiredAcks RequiredAcks // The level of acknowledgement reliability needed from the broker (defaults to WaitForLocal). Equivalent to the `request.required.acks` setting of the JVM producer.
|
|
|
+ Timeout time.Duration // The maximum duration the broker will wait the receipt of the number of RequiredAcks (defaults to 10 seconds). This is only relevant when RequiredAcks is set to WaitForAll or a number > 1. Only supports millisecond resolution, nanoseconds will be truncated. Equivalent to the JVM producer's `request.timeout.ms` setting.
|
|
|
+ Compression CompressionCodec // The type of compression to use on messages (defaults to no compression). Similar to `compression.codec` setting of the JVM producer.
|
|
|
+ FlushMsgCount int // The number of messages needed to trigger a flush. This is a best effort; the number of messages may be more or less. Use `MaxMessagesPerReq` to set a hard upper limit.
|
|
|
+ FlushFrequency time.Duration // If this amount of time elapses without a flush, one will be queued. The frequency is a best effort, and the actual frequency can be more or less. Equivalent to `queue.buffering.max.ms` setting of JVM producer.
|
|
|
+ FlushByteCount int // If this many bytes of messages are accumulated, a flush will be triggered. This is a best effort; the number of bytes may be more or less. Use the gloabl `sarama.MaxRequestSize` to set a hard upper limit.
|
|
|
AckSuccesses bool // If enabled, successfully delivered messages will be returned on the Successes channel.
|
|
|
- MaxMessageBytes int // The maximum permitted size of a message (defaults to 1000000)
|
|
|
- MaxMessagesPerReq int // The maximum number of messages the producer will send in a single broker request. Defaults to 0 for unlimited. The global setting MaxRequestSize still applies.
|
|
|
- ChannelBufferSize int // The size of the buffers of the channels between the different goroutines. Defaults to 0 (unbuffered).
|
|
|
- RetryBackoff time.Duration // The amount of time to wait for the cluster to elect a new leader before processing retries. Defaults to 250ms.
|
|
|
+ MaxMessageBytes int // The maximum permitted size of a message (defaults to 1000000). Equivalent to the broker's `message.max.bytes`.
|
|
|
+ MaxMessagesPerReq int // The maximum number of messages the producer will send in a single broker request. Defaults to 0 for unlimited. The global setting MaxRequestSize still applies. Similar to `queue.buffering.max.messages` in the JVM producer.
|
|
|
+ ChannelBufferSize int // The size of the buffers of the channels between the different goroutines (defaults to 0, i.e. unbuffered).
|
|
|
+ RetryBackoff time.Duration // The amount of time to wait for the cluster to elect a new leader before processing retries (defaults to 250ms). Similar to the retry.backoff.ms setting of the JVM producer
|
|
|
}
|
|
|
|
|
|
// NewProducerConfig creates a new ProducerConfig instance with sensible defaults.
|