Last active
December 9, 2018 13:17
-
-
Save Solution/99ae965c80b2103d096593ad636bcc48 to your computer and use it in GitHub Desktop.
Upper part of consumer
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
func (c Consumer) Consume(interruptor *grupttor.Grupttor) q.ConsumeFunc { | |
return func(deliveries <-chan amqp.Delivery, done chan error) { | |
defer func() { | |
if r := recover(); r != nil { | |
err := errors.New(fmt.Sprintf("internal goroutine paniced: %v", r)) | |
log.Error(err) | |
// print out the stack | |
log.Error(string(debug.Stack())) | |
done <- err | |
} | |
if interruptor.IsInterrupting() { | |
// everything ok, just stop | |
interruptor.Stop() | |
} | |
done <- nil //routine done without errors | |
}() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment