-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Description
Currently, CBOR support in Fiber is implemented with direct imports of the github.com/fxamacker/cbor/v2 library, while the new MsgPack implementation (PR #3565) uses an opt-in pattern with binder mock functions to avoid forcing dependencies on rarely used serialization libraries.
Current State
CBOR (current implementation):
- Direct import of
github.com/fxamacker/cbor/v2 - Uses
cbor.Marshalandcbor.Unmarshalas defaults - Forces dependency on all users
MsgPack (new pattern):
- Uses
binder.UnimplementedMsgpackMarshalandbinder.UnimplementedMsgpackUnmarshalas defaults - Mock functions panic if called without explicit setup
- Allows users to opt-in by configuring their preferred MsgPack library
Proposed Changes
Refactor CBOR implementation to follow the MsgPack pattern:
- Create
binder.UnimplementedCborMarshalandbinder.UnimplementedCborUnmarshalfunctions - Set these as defaults in the Config struct instead of
cbor.Marshal/cbor.Unmarshal - Remove direct
github.com/fxamacker/cbor/v2import from core app - Update documentation to show users how to explicitly configure CBOR support
- Maintain backward compatibility where possible
Benefits
- Reduces binary size for users who don't use CBOR
- Follows the opt-in philosophy for non-standard serialization formats
- Consistent approach across MsgPack and CBOR implementations
- Allows users to choose their preferred CBOR library
Context
This refactoring was discussed in PR #3565 (MsgPack implementation):
Related
- Part of the broader serialization architecture improvements
- Could be extended to other non-standard formats in the future
- Aligns with the plugin-based registry pattern discussion for Fiber v3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels