-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from lovoo/sarama-config
let producerBuilder set partitioner in sarama.Config
- Loading branch information
Showing
10 changed files
with
114 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package kafka | ||
|
||
import ( | ||
"github.com/Shopify/sarama" | ||
cluster "github.com/bsm/sarama-cluster" | ||
metrics "github.com/rcrowley/go-metrics" | ||
) | ||
|
||
// CreateDefaultSaramaConfig creates a (bsm) sarama configuration with default values. | ||
func CreateDefaultSaramaConfig(clientID string, partitioner sarama.PartitionerConstructor, registry metrics.Registry) *cluster.Config { | ||
config := cluster.NewConfig() | ||
|
||
config.Version = sarama.V0_10_1_0 | ||
config.ClientID = clientID | ||
config.ChannelBufferSize = defaultChannelBufferSize | ||
|
||
// consumer configuration | ||
config.Consumer.Return.Errors = true | ||
config.Consumer.Offsets.Initial = sarama.OffsetOldest | ||
config.Consumer.MaxProcessingTime = defaultMaxProcessingTime | ||
|
||
// producer configuration | ||
config.Producer.RequiredAcks = sarama.WaitForLocal | ||
config.Producer.Compression = sarama.CompressionSnappy | ||
config.Producer.Flush.Frequency = defaultFlushFrequency | ||
config.Producer.Flush.Bytes = defaultFlushBytes | ||
config.Producer.Return.Successes = true | ||
config.Producer.Return.Errors = true | ||
config.Producer.Retry.Max = defaultProducerMaxRetries | ||
|
||
// consumer group configuration | ||
config.Group.Return.Notifications = true | ||
|
||
// register registry to get kafka metrics | ||
config.Config.MetricRegistry = registry | ||
|
||
// set partitioner | ||
if partitioner != nil { | ||
config.Producer.Partitioner = partitioner | ||
} | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters