Ver Fonte

Adds back Consumer.Offsets.CommitInterval to fix API

fix breaking API change added in
https://github.com/Shopify/sarama/pull/1164

Fixes:
- https://github.com/bsm/sarama-cluster/pull/308
- https://github.com/bsm/sarama-cluster/issues/307
- https://github.com/lovoo/goka/issues/211
Diego Alvarez há 5 anos atrás
pai
commit
b74b4a28b9
1 ficheiros alterados com 10 adições e 0 exclusões
  1. 10 0
      config.go

+ 10 - 0
config.go

@@ -352,6 +352,11 @@ type Config struct {
 		// offsets. This currently requires the manual use of an OffsetManager
 		// but will eventually be automated.
 		Offsets struct {
+			// Deprecated: CommitInterval exists for historical compatibility
+			// and should not be used. Please use Consumer.Offsets.AutoCommit
+			CommitInterval time.Duration
+
+			// AutoCommit specifies configuration for commit messages automatically.
 			AutoCommit struct {
 				// Whether or not to auto-commit updated offsets back to the broker.
 				// (default enabled).
@@ -688,6 +693,11 @@ func (c *Config) Validate() error {
 		return ConfigurationError("Consumer.IsolationLevel must be ReadUncommitted or ReadCommitted")
 	}
 
+	if c.Consumer.Offsets.CommitInterval != 0 {
+		Logger.Println("Deprecation warning: Consumer.Offsets.CommitInterval exists for historical compatibility" +
+			" and should not be used. Please use Consumer.Offsets.AutoCommit, the current value will be ignored")
+	}
+
 	// validate IsolationLevel
 	if c.Consumer.IsolationLevel == ReadCommitted && !c.Version.IsAtLeast(V0_11_0_0) {
 		return ConfigurationError("ReadCommitted requires Version >= V0_11_0_0")