wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
785 stars 128 forks source link

Return an error instead of crashing when we cannot retry consumer #145

Closed hugowetterberg closed 7 months ago

hugowetterberg commented 10 months ago

This change separates the creation and running of the consumer to allow the caller to handle errors when it's not possible to retry.

A library should never call log.Fatal or os.Exit as this takes control over error handling and graceful termination away from the application developer. The Fatalf() logger method should be removed, but I didn't want to touch the producer parts as I'm not as familiar with them.

sebwalle commented 10 months ago

This bit me just yesterday. Was scratching my head a while since I had no panics in my code but eventually found the issue.