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

Compatibility mode #22

Closed
hungryblank opened this Issue Jan 29, 2016 · 7 comments

Comments

Projects
None yet
2 participants
@hungryblank

hungryblank commented Jan 29, 2016

If this library is supporting a newer version of the spec it should document if it supports compatibility mode with the old spec and how to use that:

excerpt from https://github.com/msgpack/msgpack/blob/master/spec.md

"In a major release, serializers distinguish Binary type and String type using bin format family and str format family
At the same time, serializers should offer "compatibility mode" which doesn't use bin format family and str 8 format"

@kawanet

This comment has been minimized.

Owner

kawanet commented Jan 29, 2016

Hi, The library supports the current version of msgpack spec.
The spec was released 3 years ago.
Do you know any use cases which still depend on the older binary/string type spec?

They say, by the way, msgpack would add a new official ext format for nano precision date time.
The library would follow it.

@hungryblank

This comment has been minimized.

hungryblank commented Jan 30, 2016

We run systems that were written longer than 3 years ago. For these systems there's no drop in replacement for the newer spec implementation so updating msgpack would mean getting involved in much larger scope updates or manually port the newer spec.

If you're not keen on implementing compatibility mode yourself but would consider accepting patches, could you outline an implementation for which you would consider accepting a pull request.

@kawanet

This comment has been minimized.

Owner

kawanet commented Feb 2, 2016

I see. Do you have any reference implementation of compatibility_mode on the other npm modules to have compatibility / interoperability?

Ruby implementation have compatibility_mode option for instance.
https://github.com/msgpack/msgpack-ruby/blob/master/ext/msgpack/packer.h#L418

@hungryblank

This comment has been minimized.

hungryblank commented Feb 2, 2016

Hi,

We did some research and found no other node/JavaScript library implementing compatibility mode.
I opened an issue on this library as this would be our preferred choice for a plain JavaScript implementation

As you pointed out Here's the PR for the ruby compatibility implementation

https://github.com/msgpack/msgpack-ruby/pull/68/files

Also there's this python lib that implements compatibility mode

https://github.com/vsergeev/u-msgpack-python#compatibility-mode

@kawanet

This comment has been minimized.

Owner

kawanet commented Apr 21, 2016

The compatibility mode added at version 0.1.19!

https://www.npmjs.com/package/msgpack-lite#compatibility-mode

// default mode handles both str and bin formats individually 

msgpack.encode("Aa"); // => <Buffer a2 41 61> (str format) 
msgpack.encode(new Buffer([0x41, 0x61])); // => <Buffer c4 02 41 61> (bin format) 

msgpack.decode(new Buffer([0xa2, 0x41, 0x61])); // => 'Aa' (String) 
msgpack.decode(new Buffer([0xc4, 0x02, 0x41, 0x61])); // => <Buffer 41 61> (Buffer) 

// compatibility mode handles only raw format both for String and Buffer 

var options = {codec: msgpack.createCodec({useraw: true})};

msgpack.encode("Aa", options); // => <Buffer a2 41 61> (raw format) 
msgpack.encode(new Buffer([0x41, 0x61]), options); // => <Buffer a2 41 61> (raw format) 

msgpack.decode(new Buffer([0xa2, 0x41, 0x61]), options); // => <Buffer 41 61> (Buffer) 
msgpack.decode(new Buffer([0xa2, 0x41, 0x61]), options).toString(); // => 'Aa' (String) 

@kawanet kawanet closed this Apr 21, 2016

@hungryblank

This comment has been minimized.

hungryblank commented Apr 21, 2016

thanks a lot!
Do i understand well that useraw is basically the flag that means "compatibility mode?"

@kawanet

This comment has been minimized.

Owner

kawanet commented Apr 22, 2016

useraw is basically the flag that means "compatibility mode?"

Right. The most difference is old raw format vs new str+bin formats.

var options = {codec: msgpack.createCodec({useraw: true})};

The useraw flag itself affects nothing on ext format which is not exist on the old spec.
That is why the flag's named useraw instead of compatibility_mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment