Explorar o código

producer: check MaxMessagesPerReq >= FlushMsgCount

Validate the above condition when MaxMessagesPerReq is set, as it doesn't make
sense to force a flush before one has been soft-triggered.
Evan Huus %!s(int64=11) %!d(string=hai) anos
pai
achega
dc9dbce604
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      producer.go

+ 2 - 2
producer.go

@@ -75,8 +75,8 @@ func (config *ProducerConfig) Validate() error {
 		Logger.Println("ProducerConfig.MaxMessageBytes too close to MaxRequestSize; it will be ignored.")
 	}
 
-	if config.MaxMessagesPerReq < 0 {
-		return ConfigurationError("Invalid MaxMessagesPerReq")
+	if config.MaxMessagesPerReq < 0 || (config.MaxMessagesPerReq > 0 && config.MaxMessagesPerReq < config.FlushMsgCount) {
+		return ConfigurationError("Invalid MaxMessagesPerReq, must be non-negative and >= FlushMsgCount if set")
 	}
 
 	if config.RetryBackoff < 0 {