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
.
Mux documentation
Thrift documentation
Configuration documentation
A server for the Thrift protocol served over com.twitter.finagle.mux.
A server for the Thrift protocol served over com.twitter.finagle.mux. ThriftMuxServer is backwards-compatible with Thrift clients that use the framed transport and binary protocol. It switches to the backward-compatible mode when the first request is not recognized as a valid Mux message but can be successfully handled by the underlying Thrift service. Since a Thrift message that is encoded with the binary protocol starts with a header value of 0x800100xx, Mux does not confuse it with a valid Mux message (0x80 = -128 is an invalid Mux message type) and the server can reliably detect the non-Mux Thrift client and switch to the backwards-compatible mode.
Note that the server is also compatible with non-Mux finagle-thrift clients. It correctly responds to the protocol up-negotiation request and passes the tracing information embedded in the thrift requests to Mux (which has native tracing support).
The
ThriftMux
object is both acom.twitter.finagle.Client
and acom.twitter.finagle.Server
for the Thrift protocol served over com.twitter.finagle.mux. Rich interfaces are provided to adhere to those generated from a Thrift IDL by Scrooge or thrift-finagle.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 intoThriftMux.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 = ThriftMux.client.newIface(addr, TestService.FutureIface.class);
Servers
Servers are also simple to expose:
TestService.FutureIface
must be implemented and passed intoserveIface
:This object does not expose any configuration options. Both clients and servers are instantiated with sane defaults. Clients are labeled with the "clnt/thrift" prefix and servers with "srv/thrift". If you'd like more configuration, see the configuration documentation.