Skip to content

Commit

Permalink
Validate gzip compression level support early
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Feb 12, 2018
1 parent 1f78d8a commit 1d6d3b3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package sarama

import (
"compress/gzip"
"crypto/tls"
"fmt"
"io/ioutil"
"regexp"
"time"

Expand Down Expand Up @@ -414,6 +417,12 @@ func (c *Config) Validate() error {
return ConfigurationError("lz4 compression requires Version >= V0_10_0_0")
}

if c.Producer.Compression == CompressionGZIP {
if _, err := gzip.NewWriterLevel(ioutil.Discard, c.Producer.CompressionLevel); err != nil {
return ConfigurationError(fmt.Sprintf("gzip compression does not work with level %d: %v", c.Producer.CompressionLevel, err))
}
}

// validate the Consumer values
switch {
case c.Consumer.Fetch.Min <= 0:
Expand Down

0 comments on commit 1d6d3b3

Please sign in to comment.