[NPE-719] Add PayloadHandler #74
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.
Adds
PayloadHandlerand makes it configurable so users can build custom payload handling for additional meta data or third party messaging consumption.Chore is built upon the assumption that messages published to the queue will be handled by Chore. Even though Chore allows for configuration of
payload_handler, it assumes a structure of the message that makes it difficult to do processing of messages that's not published by Chore (ie. third party streaming data). For instance, it assumes thisjob_hash:This makes it difficult to parse if the message does not correspond to this structure, for instance:
Chore determines the process to run by constantizing the class in the message which poses problems for messages published without this data.
In order to facilitate the above, the method signature for decoding the message was updated to take the
UnitOfWorkwith quite a bit of data. It also refactors code a bit to place message structure handling intoPayloadHandlerrather thanJobto cleanly separate concerns. This way, a user has control over how messages should be constructed/deconstructed. The code still breaks if you don't follow the originaljob_hash, but it allows for great flexibility on the decoding of the message without reworking a ton of Chore internals. A custom payload handler may look like this.