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 9 năm trước cách đây
mục cha
commit
686609495c
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  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) {
 	if c.Producer.Flush.Bytes >= int(MaxRequestSize) {
 		Logger.Println("Producer.Flush.Bytes must be smaller than MaxRequestSize; it will be ignored.")
 		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 {
 	if c.Producer.Timeout%time.Millisecond != 0 {
 		Logger.Println("Producer.Timeout only supports millisecond resolution; nanoseconds will be truncated.")
 		Logger.Println("Producer.Timeout only supports millisecond resolution; nanoseconds will be truncated.")
 	}
 	}