-
Notifications
You must be signed in to change notification settings - Fork 832
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
encoding/json: Add custom JSON package with build tag support for Sonic #1623
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1623 +/- ##
=======================================
Coverage 37.07% 37.07%
=======================================
Files 414 414
Lines 180274 180274
=======================================
+ Hits 66835 66845 +10
- Misses 105574 105577 +3
+ Partials 7865 7852 -13
|
Flagged this as medium because this is beast. Sorry for those that cant use it. 🙏 |
Ok cool,
I guess it comes from GCT library (as the more we update this library the further it drifts away from this and I could be completely wrong) wants to be as close to using internal dependencies as much as possible as default and all external dependencies are opt in. You're right in that this approach is being too cautious but I like that. Also it had to do with sonics different configurations Default, Fastest, Standard(aligns most closely to encoding/json). I was thinking we could have different build tags for those in future if I or somebody else ever gets around to it (other things are way more priority). Also we could hot swap in different JSON libraries if they were similar if they provide a certain use case. Anyways this is my perspective and I am not against sonic being default either. @thrasher- @gloriousCode for your input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 Great work 🎉
Only suggests again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
If you take the suggestion to make sonic the default, then I'll re-review that, obviously.
We can default sonic to on, since we're already using another json package jsonparser by default in many exchanges and other systems now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 🎉
Only a couple of minor things.
encoding/json/json.go
Outdated
|
||
package json | ||
|
||
import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. It serves as the default JSON package for GCT (GoCryptoTrader). All uses of JSON throughout the application should refer to this package with the default build. | ||
import "encoding/json" //nolint:depguard // This is a wrapper package for encoding/json. All uses of JSON throughout the application should refer to this when sonic_off build tag is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Seems like we're using the nolint as the package comment across the 3 json/*.go files.
encoding/json
is ambiguous in the comment, since it's referring togolang.org/encoding/json
but insidegct/encoding/json
- I don't think we need to say that all uses of json throughout should refer to it
So I think we want a single package comment (common.go?) and then package comments in the other two relevant to them, and then the depguard nolint comment just explains it:
// json is an abstraction middleware package to allow switching between json encoder/decoder implementations
// The default implementation is sonic.
// Build with `sonic_off` or `386` tags to switch to golang.org/encoding/json.
and
import "encoding/json" //nolint:depguard // Acceptable use in gct json wrapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30f0150
to
ad20589
Compare
README.md
Outdated
@@ -101,15 +101,11 @@ When submitting a PR, please abide by our coding guidelines: | |||
+ Code must adhere to our [coding style](https://github.com/thrasher-corp/gocryptotrader/blob/master/.github/CONTRIBUTING.md). | |||
+ Pull requests need to be based on and opened against the `master` branch. | |||
|
|||
## Compiling instructions | |||
## Compilation and run instructions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super-Duper Nit: "Compilation" tastes weird
Compiling and Running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considered also splitting sections into Compiling
and Running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK
Just a note here: |
PR Description
This pull request introduces a custom JSON package located in encoding/json/ to facilitate swapping between the default Go encoding/json package and the sonic library based on build tags.
Adds:
Import Updates:
All imports to the standard encoding/json package have been updated to the new custom package github.com/thrasher-corp/gocryptotrader/encoding/json.
Added basic benchmarks for both the default encoding/json and the sonic implementation to evaluate hot-swap performance.
Type of change
Please delete options that are not relevant and add an
x
in[]
as item is complete.How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.
Checklist