Sfoglia il codice sorgente

Merge pull request #244 from Shopify/warn-on-acks-greater-than-1

producer: add warning about RequiredAcks>1
Evan Huus 11 anni fa
parent
commit
74f18a8a1b
2 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 4 1
      produce_request.go
  2. 2 0
      producer.go

+ 4 - 1
produce_request.go

@@ -1,7 +1,10 @@
 package sarama
 
 // RequiredAcks is used in Produce Requests to tell the broker how many replica acknowledgements
-// it must see before responding. Any positive int16 value is valid, or the constants defined here.
+// it must see before responding. Any of the constants defined here are valid. On broker versions
+// prior to 0.8.2.0 any other positive int16 is also valid (the broker will wait for that many
+// acknowledgements) but in 0.8.2.0 and later this will raise an exception (it has been replaced
+// by setting the `min.isr` value in the brokers configuration).
 type RequiredAcks int16
 
 const (

+ 2 - 0
producer.go

@@ -43,6 +43,8 @@ func NewProducerConfig() *ProducerConfig {
 func (config *ProducerConfig) Validate() error {
 	if config.RequiredAcks < -1 {
 		return ConfigurationError("Invalid RequiredAcks")
+	} else if config.RequiredAcks > 1 {
+		Logger.Println("ProducerConfig.RequiredAcks > 1 is deprecated and will raise an exception with kafka >= 0.8.2.0.")
 	}
 
 	if config.Timeout < 0 {