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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gazler
Copy link

@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
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.

1 participant