浏览代码

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 9 年之前
父节点
当前提交
686609495c
共有 1 个文件被更改,包括 3 次插入0 次删除
  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.")
 	}