Skip to content

Commit

Permalink
Merge pull request #10 from mailgun/maxim/develop
Browse files Browse the repository at this point in the history
 Make kafkahook.Fire never block
  • Loading branch information
horkhe authored Dec 6, 2017
2 parents 5ee121b + 35ba57c commit e1f5c6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kafkahook/kafkahook.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func New(conf Config) (*KafkaHook, error) {
kafkaConfig.Producer.Flush.Frequency = 200 * time.Millisecond
kafkaConfig.Producer.Retry.Backoff = 10 * time.Second
kafkaConfig.Producer.Retry.Max = 6
kafkaConfig.Producer.Return.Errors = true

// If the user failed to provide a producer create one
if conf.Producer == nil {
Expand Down Expand Up @@ -111,8 +110,10 @@ func (h *KafkaHook) sendKafka(buf []byte) error {
Topic: h.topic,
Key: nil,
}:
case err := <-h.producer.Errors():
return err
default:
// If the producer input channel buffer is full, then we better drop
// a log record than block program execution.
fmt.Fprintf(os.Stderr, "kafkahook buffer overflow: %s\n", string(buf))
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.1

0 comments on commit e1f5c6d

Please sign in to comment.