Kitex only support Thrift Binary protocol codec, Compact currently is not supported.
If you are using thrift protocol encoding, codes should be generated by kitex cmd tool:
Client side:
kitex -type thrift ${service_name} ${idl_name}.thrift
Server side:
kitex -type thrift -service ${service_name} ${idl_name}.thrift
We have optimized Thrift’s Binary protocol codec. For details of the optimization, please refer to the “Reference - High Performance Thrift Codec” chapter. If you want to close these optimizations, you can add the -no-fast-api
argument when generating code.
Kitex supports two types of protocol for protobuf:
If the streaming method is defined in the IDL, the serialization protocol would adopt gRPC protocol, otherwise Kitex protobuf would be adopted. If you want using gRPC protocol, but without stream definition in your proto file, you need specify the transport protocol when initializing client (No changes need to be made on the server because protocol detection is supported):
// Using WithTransportProtocol specify the transport protocol
cli, err := service.NewClient(destService, client.WithTransportProtocol(transport.GRPC))
Only support proto3, the grammar reference: https://developers.google.com/protocol-buffers/docs/gotutorial.
Notice:
go_package
in the proto filego_package
specify the package name, such as: go_package = “pbdemo”protoc
binary and put it in the $PATH directoryClient side:
kitex -type protobuf -I idl/ idl/${proto_name}.proto
Server side:
kitex -type protobuf -service ${service_name} -I idl/ idl/${proto_name}.proto