Documenting Publishing.Expiration usage #232
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So this one got me good on a really nasty bug from my side. I was using the pkg to publish big batches of messages to a queue. When reading the source code it was not clear to me the value was used as milliseconds. I assumed wrongly if the value is
0
the message will not expire. I assumed this because0
would be the nil value for a go int. This assumption was painfully wrong - which lead to all messages not immediately retrieved by the consumer to get rightfully deleted. I wanted to spare others from the same mistake.I am perfectly aware the rabbit mq documentation states the usage here: https://www.rabbitmq.com/ttl.html#per-message-ttl-in-publishers
But I think a little more documentation in the code and some clarification can prevent others from making the same mistake. I also provided two constants for the field that further elaborate on the usage and should explain it in its entirety. They are not needed but so are the
DeliveryMode
constants (Transient, Persistent). If this is not wanted please provide feedback and I will refine the PR.Best regards and thank you all a lot for your work on this client!