Skip to content

Commit

Permalink
Merge pull request #104 from lovoo/bugfix/103-propagate-emitter-error
Browse files Browse the repository at this point in the history
bugfix #103: propagate error in Emitter.EmitSync
  • Loading branch information
frairon committed Mar 8, 2018
2 parents b7b94ac + 75c0908 commit 369663c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,23 @@ func (e *Emitter) Emit(key string, msg interface{}) (*kafka.Promise, error) {

// EmitSync sends a message to passed topic and key
func (e *Emitter) EmitSync(key string, msg interface{}) error {
promise, err := e.Emit(key, msg)
var (
err error
promise *kafka.Promise
)
promise, err = e.Emit(key, msg)

if err != nil {
return err
}

done := make(chan struct{})
promise.Then(func(err error) {
promise.Then(func(asyncErr error) {
err = asyncErr
close(done)
})
<-done
return nil
return err
}

// Finish waits until the emitter is finished producing all pending messages
Expand Down

0 comments on commit 369663c

Please sign in to comment.