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

Support using convert/update for extension for msgpack codec. #82

Closed
wants to merge 1 commit into from

Conversation

gabriel
Copy link

@gabriel gabriel commented Jul 8, 2015

The msgpack codec assumes WriteExt/ReadExt so the (time) example at http://ugorji.net/blog/go-codec-primer#using-extensions wouldn't work.
This patch allows you to tell it to use ConvertExt/UpdateExt instead.

The msgpack codec assumes WriteExt/ReadExt so the (time) example at http://ugorji.net/blog/go-codec-primer#using-extensions wouldn't work.
This patch allows you to tell it to use ConvertExt/UpdateExt instead.
@ugorji
Copy link
Owner

ugorji commented Jul 11, 2015

Hi,

This solution doesn't fit in with the design of messagepack extensions, which requires that a tag and the length of the subsequent number of bytes be prefixed in the stream, before the encoding happens.

As you see from your changes, the tag is not written and the number of bytes is not inferred before you attempt encoding the value. This means it is not a true msgpack extension, and will probably fail during decoding even on if using the go library. It will also fail when using other libraries.

This only works where the format specifically designs extension support that way (e.g. cbor).

@ugorji ugorji closed this Jul 11, 2015
@gabriel
Copy link
Author

gabriel commented Jul 13, 2015

Is there a way to hook into the codec to do conversions? (That was the intent of this patch.)

For example I wanted to do something like the TimeExt example (which uses ConvertExt/UpdateExt in the msgpack and cbor codec.) Only msgpack uses the WriteExt/ReadExt.

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.

2 participants