The ThriftMux
object is both a com.twitter.finagle.Client
and a
com.twitter.finagle.Server
for the Thrift protocol served over
com.twitter.finagle.mux.
The ThriftMux
object is both a com.twitter.finagle.Client
and a
com.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 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
into ThriftMux.Client.newIface
:
ThriftMux.client.newIface[TestService.FutureIface]( addr, classOf[TestService.FutureIface])
However note that the Scala compiler can insert the latter
Class
for us, for which another variant of newIface
is
provided:
ThriftMux.client.newIface[TestService.FutureIface](addr)
In Java, we need to provide the class object:
TestService.FutureIface client =
ThriftMux.client.newIface(addr, TestService.FutureIface.class);
Servers are also simple to expose:
TestService.FutureIface
must be implemented and passed
into serveIface
:
// An echo service ThriftMux.server.serveIface(":*", new TestService.FutureIface { def query(x: String): Future[String] = Future.value(x) })
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.