Browse Source

Add a config warning for unusual flushes

In Producer.Flush, if Bytes or Messages is set but Frequency is not then
messages may not get flushed because Sarama will wait forever to fulfill
the Byte/Message configurations.
Evan Huus 8 years ago
parent
commit
686609495c
1 changed files with 3 additions and 0 deletions
  1. 3 0
      config.go

+ 3 - 0
config.go

@@ -310,6 +310,9 @@ func (c *Config) Validate() error {
 	if c.Producer.Flush.Bytes >= int(MaxRequestSize) {
 		Logger.Println("Producer.Flush.Bytes must be smaller than MaxRequestSize; it will be ignored.")
 	}
+	if (c.Producer.Flush.Bytes > 0 || c.Producer.Flush.Messages > 0) && c.Producer.Flush.Frequency == 0 {
+		Logger.Println("Producer.Flush: Bytes or Messages are set, but Frequency is not; messages may not get flushed.")
+	}
 	if c.Producer.Timeout%time.Millisecond != 0 {
 		Logger.Println("Producer.Timeout only supports millisecond resolution; nanoseconds will be truncated.")
 	}