Skip to content
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

Merged
merged 7 commits into from
Aug 4, 2022
Merged

Conversation

oleg-jukovec
Copy link
Collaborator

@oleg-jukovec oleg-jukovec commented May 19, 2022

I found incompatibilities between msgpack.v2 and msgpack.v5 which affect our code:

  1. EncodeUint64/EncodeInt64 logic:
    msgpack.v2
    msgpack.v5

  2. EncodeInt/EncodeUint signature:
    https://pkg.go.dev/github.com/vmihailenco/msgpack@v2.9.2+incompatible#Encoder.EncodeUint
    https://pkg.go.dev/github.com/vmihailenco/msgpack@v2.9.2+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

  3. RegisterExt logic and signature:
    msgpack.v2
    msgpack.v5

  4. Decode Map logic:
    [decode] regression from v4: invalid code=d3 decoding string/bytes length on complex nested structure vmihailenco/msgpack#327
    https://msgpack.uptrace.dev/guide/#decoding-maps-into-an-interface/

  5. 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 provide msgpack.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

@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch 6 times, most recently from 99637ab to d5a0c38 Compare May 30, 2022 09:45
@oleg-jukovec
Copy link
Collaborator Author

oleg-jukovec commented May 30, 2022

Changes:

  • Rewrote the message for the pull request.
  • Rewrote messages for commits.
  • Added msgpack.v5 migration section into README.md.
  • msgpack.v2 still used by default instead of replace with msgpack.v5.

It is ready for review now.

@oleg-jukovec oleg-jukovec marked this pull request as ready for review May 30, 2022 09:50
@oleg-jukovec oleg-jukovec requested review from AnaNek and vr009 May 30, 2022 12:27
@oleg-jukovec oleg-jukovec changed the title Migration to msgpack v5 Optional support of msgpack.v5 May 30, 2022
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch 4 times, most recently from 72a16f9 to a49009b Compare June 2, 2022 15:50
Copy link

@vr009 vr009 left a 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.

msgpack.go Show resolved Hide resolved
tarantool_test.go Show resolved Hide resolved
Copy link

@AnaNek AnaNek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks.

@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch 3 times, most recently from 901dda2 to 3bb200d Compare June 8, 2022 13:49
@Totktonada Totktonada self-requested a review June 9, 2022 10:23
Copy link
Member

@DifferentialOrange DifferentialOrange left a 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.

schema.go Outdated Show resolved Hide resolved
schema.go Outdated Show resolved Hide resolved
schema.go Outdated Show resolved Hide resolved
client_tools.go Show resolved Hide resolved
client_tools.go Outdated Show resolved Hide resolved
tarantool_test.go Show resolved Hide resolved
tarantool_test.go Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch 4 times, most recently from ebd9208 to 1e22635 Compare July 6, 2022 14:00
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch from 1e22635 to 8c49242 Compare July 14, 2022 12:46
@oleg-jukovec oleg-jukovec removed the request for review from Totktonada July 14, 2022 12:52
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch from 8c49242 to 271a891 Compare July 22, 2022 10:53
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch 8 times, most recently from 497d980 to 72eb5b9 Compare August 3, 2022 07:21
README.md Outdated Show resolved Hide resolved
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch from 72eb5b9 to 827612b Compare August 3, 2022 08:07
Copy link
Member

@DifferentialOrange DifferentialOrange left a 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

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
call_16_test.go Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch from 827612b to 51a5b60 Compare August 3, 2022 08:49
oleg-jukovec and others added 7 commits August 4, 2022 14:23
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 <oleg_utkin@me.com>
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
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
@oleg-jukovec oleg-jukovec force-pushed the oleg-jukovec/gh-124-msgpack-v5 branch from 51a5b60 to 67653e9 Compare August 4, 2022 11:24
@oleg-jukovec oleg-jukovec merged commit 65a6de4 into master Aug 4, 2022
@oleg-jukovec oleg-jukovec deleted the oleg-jukovec/gh-124-msgpack-v5 branch August 4, 2022 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt vmihailenco/msgpack v5
4 participants