Unmarshaller more resiliant and clearer error if uuid header is missing #40
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.
Motivation / Background
I was having issues testing the application using default marshaller and setting the whole thing up as a subscriber listening to a topic and trying to send messages using redis-cli by hand. The thing is that I wasn't sending any uuid header and there wasn't an explicit error in the code to let me know what was happening so I added because I think it is for a better understanding to everyone who try this application that way.
Details
Inside marshaller.go archive, the one that is used as a DefaultMarshaller, inside Unmarshall function, there was an explicit conversion of an interface type variable to a string for an UUID header value and also the payload of the message. I know the marshaller is really basic and it is advisable to use a custom one but I think is clearer for testing purposes if it is added a little
ifas a check to see if UUID header has been sent in order to warn the user if not and to give "payload" a base value in case it is empty because it will panic otherwise because of a forced nil conversion into a string value.Alternative approaches considered (if applicable)
Checklist
The resources of our team are limited. There are a couple of things that you can do to help us merge your PR faster:
make up.make test_shortfor a quick check.make test.