feat: port Realtime V2 serializer from supabase-js PRs #1829, #1894#1325
Open
feat: port Realtime V2 serializer from supabase-js PRs #1829, #1894#1325
Conversation
This implements the Realtime V2 serializer based on supabase-js PRs #1829 and #1894. Key features: - Binary payload support for user messages - Two new message types: user broadcast and user broadcast push - Optional metadata support for user broadcast push messages - Reduced JSON encoding overhead on the server side - Backward compatible with V1 (1.0.0) as default Changes: - Added Serializer class with binary encoding/decoding support - Updated types.py to add VSN constants (VSN_1_0_0, VSN_2_0_0, DEFAULT_VSN) - Updated AsyncRealtimeClient to support vsn parameter and serializer selection - Added comprehensive test suite with 16 tests covering encoding/decoding scenarios - Metadata filtering based on allowed_metadata_keys parameter References: - supabase/supabase-js#1829 - supabase/supabase-js#1894
- Add class-level type annotation for serializer: Optional[Serializer] - Add type annotation for message_data: Union[str, bytes] - Fix type compatibility issues with websocket send method
- Fix JSON encoding to use compact format (no spaces) to match expected output - Fix metadata extraction to exclude special fields (type, event, payload) - Fix broadcast decoding offset calculation - Fix metadata start position calculation in test - Update metadata length validation test to use sufficient length
Pull Request Test Coverage Report for Build 19963050962Details
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Ports Realtime V2 serializer feature from supabase-js PRs #1829 and #1894.
Source
Changes
From PR #1829
Serializerclass with binary encoding/decoding supporttypes.pyto add VSN constants (VSN_1_0_0,VSN_2_0_0,DEFAULT_VSN)AsyncRealtimeClientto supportvsnparameter and serializer selectionFrom PR #1894
allowed_metadata_keysparameterCombined Changes
vsn="2.0.0"toAsyncRealtimeClientTesting
Breaking Changes
None - This PR contains no breaking changes. The default serializer version remains 1.0.0, and V2 is opt-in.
Notes
bytesandbytearraytypes_pickhelper method similar to the JS implementationvsnparameter inAsyncRealtimeClientallowed_metadata_keysparameterReferences