-
Notifications
You must be signed in to change notification settings - Fork 59
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
Optional support of msgpack.v5 #174
Conversation
99637ab
to
d5a0c38
Compare
Changes:
It is ready for review now. |
72a16f9
to
a49009b
Compare
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.
In general this patch looks good to me. I'm not familiar with optional build in go and
some link in CONTRIBUTING.md
would be very helpful with understanding of this mechanism.
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.
LGTM! Thanks.
901dda2
to
3bb200d
Compare
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.
This patch seems awesome (especially separated commits for complicated changes), thank you!
I have left several comment while trying to better understand what is going on.
ebd9208
to
1e22635
Compare
1e22635
to
8c49242
Compare
8c49242
to
271a891
Compare
497d980
to
72eb5b9
Compare
72eb5b9
to
827612b
Compare
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.
Should be ok after resolving remaining comments
827612b
to
51a5b60
Compare
EncodeSliceLen[1] and DecodeSliceLen[2] are marked as deprecated in msgpack v2.9.2. The patch replaces it with EncodeArrayLen and DecodeArrayLen. 1. https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#Encoder.EncodeSliceLen 2. https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#Decoder.DecodeSliceLen Part of #124
We use everywhere EncodeInt instead of EncodeInt64. Also we use everywhere EncodeUint64 instead of EncodeUint. It can be confusing. Although EncodeUint64 and EncodeUint have same logic in msgpack.v2, but different in msgpack.v5. It's good for migration to msgpack.v5 too. Part of #124.
When we decode the schema with msgpack it allows us to handle errors better. For example, incorrect type conversion leads to a runtime error. Now it will be an usual error that we can handle by our code. Also it will help in migration to msgpack.v5, because an interface decoding rules by default have changed in msgpack.v5. Part of #124 Co-authored-by: Oleg Utkin <[email protected]>
The patch replaces the msgpack code by internal wrappers. The msgpack usage have been extracted to msgpack.go file for the code and to msgpack_helper_test.go for tests. It is the same logic for submodules. Part of #124
EncodeUint and EncodeInt have different argument types in msgpack.v2[1][2] and msgpack.v5[3][4]. The wrappers will simplify migration to msgpack.v5. 1. https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#Encoder.EncodeUint 2. https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#Encoder.EncodeInt 3. https://pkg.go.dev/github.com/vmihailenco/msgpack/v5#Encoder.EncodeUint 4. https://pkg.go.dev/github.com/vmihailenco/msgpack/v5#Encoder.EncodeInt Part of #124
The msgpack.v5 code located in msgpack_v5.go and msgpack_v5_helper_test.go for tests. It is the same logic for submodules. An user can use msgpack.v5 with a build tag: go_tarantool_msgpack_v5 The commit also unify typo conversions after decoding in tests. This is necessary because msgpack v2.9.2 decodes all numbers as uint[1] or int[2], but msgpack.v5 decodes numbers as a MessagePack type[3]. There are additional differences when decoding types. 1. https://github.com/vmihailenco/msgpack/blob/23644a15054d8b9f8a9fca3e041f3419504b9c21/decode.go#L283 2. https://github.com/vmihailenco/msgpack/blob/23644a15054d8b9f8a9fca3e041f3419504b9c21/decode.go#L285 3. https://github.com/vmihailenco/msgpack/blob/233c977ae92b215a9aa7eb420bbe67da99f05ab6/decode.go#L410 Part of #124
51a5b60
to
67653e9
Compare
I found incompatibilities between msgpack.v2 and msgpack.v5 which affect our code:
EncodeUint64/EncodeInt64 logic:
msgpack.v2
msgpack.v5
EncodeInt/EncodeUint signature:
https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#Encoder.EncodeUint
https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#Encoder.EncodeInt
https://pkg.go.dev/github.com/vmihailenco/msgpack/v5#Encoder.EncodeUint
https://pkg.go.dev/github.com/vmihailenco/msgpack/v5#Encoder.EncodeInt
RegisterExt logic and signature:
msgpack.v2
msgpack.v5
Decode Map logic:
[decode] regression from v4:
invalid code=d3 decoding string/bytes length
on complex nested structure vmihailenco/msgpack#327https://msgpack.uptrace.dev/guide/#decoding-maps-into-an-interface/
Decode numbers logic:
msgpack.v2
msgpack.v5
Most of the problems can be solved easily and do not affect a
go-tarantool
clients code (1, 2, 3, 4), but it is impossible to get the same decoding logic for all cases (5). The changes will break the client code.The pull request solves problems for the
go-tarantool
code and providemsgpack.v5
as an option for the current version. In the future,msgpack.v5
may be used by default.I didn't forget about (remove if it is not applicable):
Related issues:
Closes #124