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 years ago
parent
commit
bf998b4731
1 changed files with 4 additions and 0 deletions
  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")
 	}