A Filter
for Thrift services that enforces all
requests specify a com.twitter.finagle.thrift.ClientId
.
Used by Thrift and ThriftMux to facilitate giving the Finagle stack access to the deserialized forms of Thrift requests and responses.
Used by Thrift and ThriftMux to facilitate giving the Finagle stack access to the deserialized forms of Thrift requests and responses.
When using Scrooge for code
generation, a proper DeserializationCtx
will be available
to code via Contexts.local(DeserializeCtx.Key)
.
While this is thread-safe, it should only be used for the life of a single request/response pair.
Indicates that the connection on which a Thrift request was issued is invalid, where "validity" is determined by com.twitter.finagle.thrift.ValidateThriftService.
Indicates that a request without a com.twitter.finagle.thrift.ClientId
was issued to a server that requires them.
Indicates that a request without a com.twitter.finagle.thrift.ClientId
was issued to a server that requires them. See
com.twitter.finagle.thrift.ClientIdRequiredFilter for details.
Produce a client with params wrapped in RichClientParam
Produce a client with params wrapped in RichClientParam
A TProtocolFactory
creates protocol objects from transports
For client stats, (default: empty string)
The max size of a reusable buffer for the thrift response
StatsReceiver for recording metrics
Produce a server with params wrapped in RichServerParam
Produce a server with params wrapped in RichServerParam
A TProtocolFactory
creates protocol objects from transports
For server stats, (default: "thrift")
The max size of a reusable buffer for the thrift response
StatsReceiver for recording metrics
A Filter
that overrides Thrift request sequence IDs,
replacing them with our own randomly-assigned i32s.
A Filter
that overrides Thrift request sequence IDs,
replacing them with our own randomly-assigned i32s. Upon response receipt,
this filter ensures that responses have the correct corresponding sequence ID,
failing any requests that do not.
This only works when using BinaryProtocol.
Indicates that a Thrift response did not have the correct sequence ID according to that assigned by com.twitter.finagle.thrift.SeqIdFilter on the corresponding request.
A mixin trait to provide a rich Thrift client API.
A mixin trait to provide a rich Thrift server API.
A filter that invalidates a connection if it suffers from an irrecoverable application exception.
A filter that invalidates a connection if it suffers from an irrecoverable application exception.
Amazingly, an Apache Thrift server will leave a connection in a bad state without closing it, and furthermore only expose such errors as an "application" exception.
All we can do is sigh, pinch our noses, and apply
ValidateThriftService
.
A typeclass to construct a MethodIface by wrapping a ServiceIface.
A typeclass to construct a MethodIface by wrapping a ServiceIface. This is a compatibility constructor to replace an existing Future interface with one built from a ServiceIface.
Scrooge generates implementations of this builder.
(Since version 2017-11-13) Use com.twitter.finagle.thrift.service.MethodPerEndpointBuilder
Typeclass ServiceIfaceBuilder[T] creates T-typed interfaces from thrift clients.
Typeclass ServiceIfaceBuilder[T] creates T-typed interfaces from thrift clients. Scrooge generates implementations of this builder.
(Since version 2017-11-13) Use com.twitter.finagle.thrift.service.ServicePerEndpointBuilder
Construct Service interface for a Thrift method.
Construct Service interface for a Thrift method.
There are two ways to use a Scrooge-generated Thrift Service
with Finagle:
1. Using a Service interface, i.e. a collection of Finagle Services
.
2. Using a method interface, i.e. a collection of methods returning Futures
.
Example: for a Thrift service IDL:
service Logger { string log(1: string message, 2: i32 logLevel); i32 getLogSize(); }
the Service
interface, or ServiceIface
, is
trait LoggerServiceIface { val log: com.twitter.finagle.Service[Logger.Log.Args, Logger.Log.SuccessType] val getLogSize: com.twitter.finagle.Service[Logger.GetLogSize.Args, Logger.GetLogSize.SuccessType] }
and the method interface, or MethodIface
, is
trait Logger[Future] { def log(message: String, logLevel: Int): Future[String] def getLogSize(): Future[Int] }
Service interfaces can be modified and composed with Finagle Filters
.
Deprecation
Please use the new interface, com.twitter.finagle.Thrift, for constructing Thrift clients and servers.
Thrift codecs
We provide client and server protocol support for the framed protocol. The public implementations are defined on the Thrift object:
The type of the server codec is
Service[Array[Byte], Array[Byte]]
and the client codecs areService[ThriftClientRequest, Array[Byte]]
. The service provided is that of a "transport" of thrift messages (requests and replies) according to the protocol chosen. This is why the client codecs need to have access to a thriftProtocolFactory
.These transports are used by the services produced by the finagle thrift codegenerator.
In this example,
Hello
is the thrift interface, and the inner classServiceToClient
is provided by the finagle thrift code generator.