Browse Source

Require a non-zero timeout when WaitForAll

Otherwise requests are almost bound to fail - there's no good reason for this
config.
Evan Huus 11 năm trước cách đây
mục cha
commit
bf998b4731
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 4 0
      producer.go

+ 4 - 0
producer.go

@@ -53,6 +53,10 @@ func (config *ProducerConfig) Validate() error {
 		Logger.Println("ProducerConfig.Timeout only supports millisecond resolution; nanoseconds will be truncated.")
 	}
 
+	if config.RequiredAcks == WaitForAll && config.Timeout == 0 {
+		return ConfigurationError("If you WaitForAll you must specify a non-zero timeout to wait.")
+	}
+
 	if config.FlushMsgCount < 0 {
 		return ConfigurationError("Invalid FlushMsgCount")
 	}