Skip to content

Commit

Permalink
Merge pull request #22 from hellofresh/patch/rabbitmq-channel-handling
Browse files Browse the repository at this point in the history
Fix rare corner cases that can panic or block on channels
  • Loading branch information
puellanivis committed Nov 7, 2018
2 parents e3aa755 + f1dd7f9 commit 2c08184
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions checks/rabbitmq/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,17 @@ func New(config Config) func() error {
return err
}

done := make(chan struct{}, 1)
defer close(done)
done := make(chan struct{})

go func() {
// block until: a message is received, or message channel is closed (consume timeout)
<-messages

// release the channel resources, and unblock the receive on done below
close(done)

// now drain any incidental remaining messages
for range messages {
done <- struct{}{}
}
}()

Expand Down

0 comments on commit 2c08184

Please sign in to comment.