Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

producer: wrap partitioning in a circuit-breaker #373

Merged
merged 1 commit into from
Mar 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#### Unreleased

Improvements:
- Wrap the producer's partitioner call in a circuit-breaker so that repeatedly
broken topics don't choke throughput
([#373](https://github.com/Shopify/sarama/pull/373)).

Bug Fixes:
- Fix the producer's internal reference counting in certain unusual scenarios
([#367](https://github.com/Shopify/sarama/pull/367)).
Expand Down
5 changes: 4 additions & 1 deletion async_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,13 @@ func (p *asyncProducer) topicDispatcher() {
func (p *asyncProducer) partitionDispatcher(topic string, input chan *ProducerMessage) {
handlers := make(map[int32]chan *ProducerMessage)
partitioner := p.conf.Producer.Partitioner(topic)
breaker := breaker.New(3, 1, 10*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a bunch of circuit breakers with hard-coded settings now. Should we make the circuit breaker options available in the Config struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"a bunch" is 2, and they currently have the same settings. We might want to expose those parameters, I'm not sure if anybody really actually cares to tweak them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, I just don't care to do that work until somebody actually wants or needs it.


for msg := range input {
if msg.retries == 0 {
err := p.assignPartition(partitioner, msg)
err := breaker.Run(func() error {
return p.assignPartition(partitioner, msg)
})
if err != nil {
p.returnError(msg, err)
continue
Expand Down