Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a binary serializer #72

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

Gazler
Copy link
Contributor

@Gazler Gazler commented Jan 13, 2025

In some cases, when using Phoenix channels, it is possible to use a binary serializer. The library already has support for binary messages, but this is slightly different. With a binary serializer, all messages can be sent in a binary format, not just individual payloads. This commit changes the contract for the serializer to allow returning a binary as before, or the tuple {:binary, binary}

In the integration tests, an example binary encoder that uses term_to_binary/1 and binary_to_term/1 is used. The integration tests are run both against the existing text based serializer, and the reference binary serializer. The GoodExample has been modified to take a set of options instead of reading them from the config, although a fallback is used to minimize the number of tests updated.

In some cases, when using Phoenix channels, it is possible to use a
binary serializer. The library already has support for binary messages,
but this is slightly different. With a binary serializer, all messages
can be sent in a binary format, not just individual payloads. This
commit changes the contract for the serializer to allow returning a
binary as before, or the tuple `{:binary, binary}`

In the integration tests, an example binary encoder that uses
`term_to_binary/1` and `binary_to_term/1` is used. The integration tests
are run both against the existing text based serializer, and the
reference binary serializer. The `GoodExample` has been modified to take
a set of options instead of reading them from the config, although a
fallback is used to minimize the number of tests updated.
@the-mikedavis the-mikedavis self-requested a review January 13, 2025 22:36
for consistency with the other similar calls
Copy link
Collaborator

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this, looks great!

@the-mikedavis the-mikedavis merged commit 0fe98c4 into NFIBrokerage:main Feb 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants