Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does thrift persist unknown fields/bytes when it deserializes and serializes back again?

So the example case for this is:

I have the type Message. It is passed between server A -> B -> C Now let's say version 2.0 of the Message is created that has a couple of new fields/ids. Servers A and C know about this new format, but server B is still using the old one. All servers deserialize, inspect, serialize and send the message. Assuming that A is populating all fields (both V1.0 and V2.0 of Message), will C see the populated fields of Message V2.0?

I know that protocol buffers supports this. I wanted to know whether Thrift supports it as well. (on a quick test I did in C#, the answer is no but just wanted to check with everyone)

As an example of the Message code, here it goes on IDL:

struct Message { // V1.0
  1: i64 Id;
}

.

struct Message { // V2.0
  1: i64 Id;
  2: string Content;
}

Will server C see Message.Content that was populated in A?

like image 442
rui Avatar asked Nov 12 '22 13:11

rui


1 Answers

The answer is no.

Regarding Protocol Buffers, it is also important to notice that according to the documentation the Python version of the generated code does not support this.

https://developers.google.com/protocol-buffers/docs/encoding#order - "If a message has unknown fields, the current Java and C++ implementations write them in arbitrary order after the sequentially-ordered known fields. The current Python implementation does not track unknown fields."

like image 158
rui Avatar answered Nov 15 '22 04:11

rui