-
Notifications
You must be signed in to change notification settings - Fork 8
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
Hope to be supported by deserialization to the interface. #7
Comments
By default in zebrapack, all structs are written as msgpack maps and contain an additional field with the name of the struct as the value. The key is number -1 for that field. Search the generated code for the phrase "runtime struct type identification" and you'll see. This can be turned off with the flag |
Yes, I see the 0xFF field has a structure name. Manually read the 0xFF can only manually read the field after the manual combination of structure, and this is very troublesome. Server, client communication If the client can issue a variety of different request types, the server can not determine the deserialization of the structure type. Would like to ask this situation should be how to use better? |
This is incorrect. The -1 field is included in the map count. |
Yes, typically one sends a header message that is always the same, and the header contains a message type indicator. The type indicator matches the message that follows. |
Sorry, my English is no good. I mean the structure name field behind MapHeader, if my code would like to read the structure name field first read the MapHeader, so UnmarshalMsg can not work. Is there any interest in increasing deserialization to interface {} function? I have time to try to add this two days. Feel and gob similar to the realization of the way, pre-registered structure name, and then deserialization according to the name of the structure to generate the corresponding structure. Hardcuts can also be implemented by adding the init () function to x_gen.go, which registers its own deserialization interface with global variables. The actual deserialization to interface {} can work like this:
You can also try to change the structure name int number of the way, should be able to save the transmission space and speed. |
I won't be able to work on this, but if you'd like to send a pull request, which must include tests of any new functionality, I will be happy to review it. |
Sorry, recently more busy. |
Hope to be supported by deserialization to the interface.
Server and client communication Sometimes the server can not determine the type of the next packet of the client, this time want to support deserialization to the interface function, the Pack interface provides GetType () method to get the actual type and processing.
The current serialization is accompanied by the name of the structure, deserialization can be determined according to this should be deserialized to what structure.
I did not find a way to read the serialized structure name without loss, and it seems that in order to support deserialization to the structure, only the library itself can be modified.
example:
The text was updated successfully, but these errors were encountered: