A ThriftMux com.twitter.finagle.Client
.
A ThriftMux com.twitter.finagle.Client
.
Mux documentation
Thrift documentation
Configuration documentation
A ThriftMux com.twitter.finagle.Server
.
A ThriftMux com.twitter.finagle.Server
.
Thrift documentation
Configuration documentation
Client and server for Apache Thrift.
Thrift
implements Thrift framed transport and binary protocol by default, though custom protocol factories (i.e. wire encoding) may be injected withwithProtocolFactory
. The client,Client[ThriftClientRequest, Array[Byte]]
provides direct access to the thrift transport, but we recommend using code generation through either Scrooge or a fork of the Apache generator. A rich API is provided to support interfaces generated with either of these code generators.The client and server uses the standard thrift protocols, with support for both framed and buffered transports. Finagle attempts to upgrade the protocol in order to ship an extra envelope carrying additional request metadata, containing, among other things, request IDs for Finagle's RPC tracing facilities.
The negotiation is simple: on connection establishment, an improbably-named method is dispatched on the server. If that method isn't found, we are dealing with a legacy thrift server, and the standard protocol is used. If the remote server is also a finagle server (or any other supporting this extension), we reply to the request, and every subsequent request is dispatched with an envelope carrying trace metadata. The envelope itself is also a Thrift struct described here.
Clients
Clients can be created directly from an interface generated from a Thrift IDL:
For example, this IDL:
service TestService { string query(1: string x) }
compiled with Scrooge, generates the interface
TestService.FutureIface
. This is then passed intoThrift.Client.newIface
:However note that the Scala compiler can insert the latter
Class
for us, for which another variant ofnewIface
is provided:In Java, we need to provide the class object:
TestService.FutureIface client = Thrift.client.newIface(addr, TestService.FutureIface.class);
The client uses the standard thrift protocols, with support for both framed and buffered transports. Finagle attempts to upgrade the protocol in order to ship an extra envelope carrying trace IDs and client IDs associated with the request. These are used by Finagle's tracing facilities and may be collected via aggregators like Zipkin.
The negotiation is simple: on connection establishment, an improbably-named method is dispatched on the server. If that method isn't found, we are dealing with a legacy thrift server, and the standard protocol is used. If the remote server is also a finagle server (or any other supporting this extension), we reply to the request, and every subsequent request is dispatched with an envelope carrying trace metadata. The envelope itself is also a Thrift struct described here.
Servers
TestService.FutureIface
must be implemented and passed intoserveIface
: