@@ -10,12 +10,12 @@ Advantages compared to the official solution:
- Support various connection types(short, connection pool). Support timeout, backup request, cancellation, tracing, built-in services, and other benefits offered by brpc.
# Compile
To reuse the parsing code, brpc depends on the thrift lib and the code generated by thrift tools to support thrift. Please read official documents to find out methods to write thrift files, generate code, compilations etc.
brpc depends on the thrift lib and the code generated by thrift tools to reuse the parsing code. Please read official documents to find out how to write thrift files, generate code, compilations etc.
brpc does not enable thrift support or depend on the thrift lib by default. If the thrift support is needed, config brpc with extra --with-thrift.
Install thrift under Ubuntu
Read [Official wiki](https://thrift.apache.org/docs/install/debian) to install depended libs and tools, then download the thrift source code from [official site](https://thrift.apache.org/download), uncompress and compile。
Read [Official wiki](https://thrift.apache.org/docs/install/debian) to install depended libs and tools, then download thrift source code from [official site](https://thrift.apache.org/download), uncompress and compile。
@@ -32,14 +32,14 @@ sh config_brpc.sh --headers=/usr/include --libs=/usr/lib --with-thrift
# Client accesses thrift server
Steps:
- Create a Channel with protocol set to brpc::PROTOCOL_THRIFT
- Define and use brpc::ThriftMessage<Native-Request> as the request, brpc::ThriftMessage<Native-Response> as the response. raw() method returns the native thrift message.
- Create a Channel setting protocol to brpc::PROTOCOL_THRIFT
- Define and use brpc::ThriftMessage<Native-Request> as the request, brpc::ThriftMessage<Native-Response> as the response. Call raw() method to get the native thrift message.
- Set method-name for thrift via Controller::set_thrift_method_name()
// example::[EchoRequest/EchoResponse] are generated by thrift
brpc::ThriftMessage<example::EchoRequest>req;
brpc::ThriftMessage<example::EchoResponse>res;
...
...
@@ -73,7 +72,7 @@ if (cntl.Failed()) {
```
# Server processes thrift requests
Inherit brpc::ThriftService to implement the processing code, which may call the native handler generated by thrift to re-use older entry directly, or read the request and set the response directly just as in other protobuf services.
Inherit brpc::ThriftService to implement the processing code, which may call the native handler generated by thrift to re-use existing entry directly, or read the request and set the response directly just as in other protobuf services.
```c++
classMyThriftProtocol:publicbrpc::ThriftService{
public:
...
...
@@ -108,7 +107,7 @@ private:
};
```
After implementing the thrift service, set to ServerOptions.thrift_service and start the service.
Set the implemented service to ServerOptions.thrift_service and start the service.