More custom codecs#94
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #94 +/- ##
==========================================
- Coverage 89.23% 89.20% -0.04%
==========================================
Files 10 13 +3
Lines 511 528 +17
==========================================
+ Hits 456 471 +15
- Misses 32 33 +1
- Partials 23 24 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modularizes anycache’s serialization layer by moving the JSON codec out of the root package and adding additional codec implementations (BSON, Gob, MessagePack) as dedicated subpackages under codec/, improving extensibility for swapping/adding codecs.
Changes:
- Moved the JSON codec implementation into
codec/jsonand updated the cache default + tests to use it. - Added new codec packages (
codec/bson,codec/gob,codec/msgpack) with corresponding unit tests. - Updated module dependencies to support the new codec implementations and refreshed documentation text.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates option documentation to mention available codecs. |
| go.mod | Adds/updates dependencies required for BSON and MessagePack support. |
| go.sum | Records checksums for newly introduced/updated transitive dependencies. |
| codec.go | Leaves only the Codec interface in the root package (removes old JSON implementation). |
| anycache.go | Switches the default codec to codec/json. |
| cache_options_test.go | Updates tests to use codec/json instead of the removed root JSON codec. |
| codec/json/json.go | Introduces JSON codec implementation in its own package. |
| codec/json/json_test.go | Moves/updates JSON codec tests for the new package. |
| codec/bson/bson.go | Adds BSON codec implementation. |
| codec/bson/bson_test.go | Adds BSON codec tests. |
| codec/gob/gob.go | Adds Gob codec implementation. |
| codec/gob/gob_test.go | Adds Gob codec tests. |
| codec/msgpack/msgpack.go | Adds MessagePack codec implementation. |
| codec/msgpack/msgpack_test.go | Adds MessagePack codec tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This pull request refactors the codec implementation to support multiple serialization formats and organizes codecs into their own packages. It removes the built-in JSON codec from the main package, introduces a modular codec structure for JSON, BSON, Gob, and MessagePack, and adds comprehensive tests for each codec. The changes improve extensibility and maintainability, making it easier to add or swap codecs.
Codec modularization and new codec support:
anycachepackage into a newcodec/jsonpackage, updating all usages and tests accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9]codec/bsonfor BSON encoding/decoding (MongoDB),codec/gobfor Go's native Gob encoding, andcodec/msgpackfor MessagePack serialization, each with their own implementation and test files. [1] [2] [3] [4] [5] [6]Code cleanup and refactoring:
JSONCodecimplementation from the maincodec.gofile, leaving only theCodecinterface definition.codec/json/json_test.goand updated it to use the new package structure.Dependency updates:
go.mod, and updated theklauspost/compressdependency version. [1] [2]