alibaba / hessian2-codec

hessian2-codec it is a complete C++ implementation of hessian2 spec
Apache License 2.0
26 stars 10 forks source link

Use Protobuf message replace Object and implement all hessian type #10

Open zyfjeff opened 3 years ago

zyfjeff commented 3 years ago

C++ does not have a global parent like Java Object, so there is no single type that can represent all hessian types, so we create an Object base class from which all hessian types are inherited. However, this Object is still not easy to use, complex to construct, and does not provide a complete API similar to that of a standard container. If we use Protobuf to define all Hessian types and use the ProtoBuf Message Object as our base Object class, we can reuse the entire Protobuf API that we provide, thus improving the overall usability.

Lynskylate commented 3 years ago

There may be some problems when using the pb type directly. For example, the key of struct type fields only accepts string.It’s hard to avoid defining a HessianStruct.

message TypeStrcut {
  string type_name = 1;
  map <Value, Value> fields;
}

Maybe it’s a good idea to use the type we defined as an intermediate type, for users to use code generated from proto idl or jar package

Dubbo can generate js code from dubbo jar.

zyfjeff commented 3 years ago

@Lynskylate We do need to use protobuf IDL to define some complex Hessian types, such as Class, Map, List, etc. The primitive types provided by Protobuf do not meet the requirements.