Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Construct a Finagle Service interface for a Scrooge-generated thrift object.
Construct a Finagle Service interface for a Scrooge-generated thrift object.
E.g. given a thrift service
service Logger { string log(1: string message, 2: i32 logLevel); i32 getLogSize(); }
you can construct a client interface with a Finagle Service per thrift method:
val loggerService = Thrift.newServiceIface[Logger.ServiceIface]("localhost:8000") val response = loggerService.log(Logger.Log.Args("log message", 1))
Address of the service to connect to, in the format accepted by Resolver.eval.
Assign a label for scoped stats.
The builder type is generated by Scrooge for a thrift service.
The Stack.Params to be used by this client.
The Stack.Params to be used by this client.
Both defaultClientName and stats predate Params
and as such are implemented separately.
Serve the interface implementation iface
, which must be generated
by either Scrooge or
thrift-finagle.
Serve the interface implementation iface
, which must be generated
by either Scrooge or
thrift-finagle.
Given the IDL:
service TestService {
string query(1: string x)
}
Scrooge will generate an interface, TestService.FutureIface
,
implementing the above IDL.
TestService.FutureIface
must be implemented and passed
into serveIface
:
Thrift.serveIface(":*", new TestService.FutureIface { def query(x: String) = Future.value(x) // (echo service) })
Note that this interface is discovered by reflection. Passing an invalid interface implementation will result in a runtime error.
Serve the interface implementation iface
, which must be generated
by either Scrooge or
thrift-finagle.
Serve the interface implementation iface
, which must be generated
by either Scrooge or
thrift-finagle.
Given the IDL:
service TestService {
string query(1: string x)
}
Scrooge will generate an interface, TestService.FutureIface
,
implementing the above IDL.
TestService.FutureIface
must be implemented and passed
into serveIface
:
Thrift.serveIface(":*", new TestService.FutureIface { def query(x: String) = Future.value(x) // (echo service) })
Note that this interface is discovered by reflection. Passing an invalid interface implementation will result in a runtime error.
(Since version 6.7.x) Use destination names
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
(Since version 6.7.x) Use destination names via newIface(String) or newIface(Name)
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
Create a new client of type Iface
, which must be generated
by either Scrooge or
thrift-finagle.
(Since version 6.7.x) Use destination names via newIface(String) or newIface(Name)
(Since version 6.7.x) Use destination names
(Since version 2015-10-26) Must provide service label
(Since version 2015-10-26) Must provide service label
(Since version 6.22.0) Use Thrift.client.withClientId
(Since version 6.22.0) Use Thrift.client.withProtocolFactory
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 https://github.com/twitter/finagle/blob/master/finagle-thrift/src/main/thrift/tracing.thrift here.
Clients
For example, this IDL:
service TestService { string query(1: string x) }
compiled with Scrooge, generates the interface
TestService.FutureIface
. This is then passed intonewIface
: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.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
: