|
@@ -2,9 +2,12 @@ package sarama
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"crypto/tls"
|
|
"crypto/tls"
|
|
|
|
|
+ "regexp"
|
|
|
"time"
|
|
"time"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+var validID *regexp.Regexp = regexp.MustCompile(`\A[A-Za-z0-9._-]*\z`)
|
|
|
|
|
+
|
|
|
// Config is used to pass multiple configuration options to Sarama's constructors.
|
|
// Config is used to pass multiple configuration options to Sarama's constructors.
|
|
|
type Config struct {
|
|
type Config struct {
|
|
|
// Net is the namespace for network-level properties used by the Broker, and
|
|
// Net is the namespace for network-level properties used by the Broker, and
|
|
@@ -353,6 +356,8 @@ func (c *Config) Validate() error {
|
|
|
switch {
|
|
switch {
|
|
|
case c.ChannelBufferSize < 0:
|
|
case c.ChannelBufferSize < 0:
|
|
|
return ConfigurationError("ChannelBufferSize must be >= 0")
|
|
return ConfigurationError("ChannelBufferSize must be >= 0")
|
|
|
|
|
+ case !validID.MatchString(c.ClientID):
|
|
|
|
|
+ return ConfigurationError("ClientID is invalid")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
return nil
|