package thrift
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 are Service[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
thrift ProtocolFactory
.
These transports are used by the services produced by the finagle thrift codegenerator.
val service: Service[ThriftClientRequest, Array[Byte]] = ClientBuilder() .hosts("foobar.com:123") .stack(Thrift.client) .build() // Wrap the raw Thrift transport in a Client decorator. The client // provides a convenient procedural interface for accessing the Thrift // server. val client = new Hello.ServiceToClient(service, protocolFactory)
In this example, Hello
is the thrift interface, and the inner
class ServiceToClient
is provided by the finagle thrift code
generator.
- Alphabetic
- By Inheritance
- thrift
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
Type Members
- trait AbstractThriftService extends AnyRef
A marker trait indicating that a service extending it was generated by Scrooge, targeting Java.
- class ClientDeserializeCtx[Rep] extends (Array[Byte]) => ReqRep
Used by Thrift and ThriftMux Client to facilitate giving the Finagle stack access to various data that are computed outside of Finagle's stack.
Used by Thrift and ThriftMux Client to facilitate giving the Finagle stack access to various data that are computed outside of Finagle's stack.
This includes:
- the deserialized forms of Thrift requests and responses.
- the name of the rpc.
- the elapsed time to serialize the request.
- the elapsed time to deserialize the response.
While this is thread-safe, it should only be used for the life of a single request/response pair.
When using Scrooge for code generation, a proper
ClientDeserializeCtx
will be available to code viaContexts.local(ClientDeserializeCtx.Key)
.- Note
this class has evolved and it's name is now a bit too specific for its more expanded role.
- case class ClientId(name: String) extends Product with Serializable
- class ClientIdRequiredFilter[Req, Rep] extends SimpleFilter[Req, Rep]
A
Filter
for Thrift services that enforces all requests specify acom.twitter.finagle.thrift.ClientId
. - abstract class GeneratedThriftService extends AnyRef
An abstract class that all scrooge-generated thrift service objects inherit directly from, including services that extend other services.
- case class InvalidThriftConnectionException() extends Exception with ServiceException with Product with Serializable
Indicates that the connection on which a Thrift request was issued is invalid, where "validity" is determined by com.twitter.finagle.thrift.ValidateThriftService.
- class MethodMetadata extends AnyRef
Stores information about the current Thrift method.
Stores information about the current Thrift method. This information is set in both Java and Scala generated code. It is expected that users will only need to interact with com.twitter.finagle.thrift.MethodMetadata.current to obtain the current MethodMetadata if it has been set.
- class NoClientIdSpecifiedException extends RequestException
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. - case class RichClientParam extends Product with Serializable
Thrift-specific parameters for configuring clients.
- case class RichServerParam(protocolFactory: TProtocolFactory = Thrift.param.protocolFactory, serviceName: String = "thrift", maxThriftBufferSize: Int = Thrift.param.maxThriftBufferSize, serverStats: StatsReceiver = LoadedStatsReceiver, responseClassifier: ResponseClassifier = ResponseClassifier.Default, perEndpointStats: Boolean = false) extends Product with Serializable
Produce a server with params wrapped in RichServerParam
Produce a server with params wrapped in RichServerParam
- protocolFactory
A
TProtocolFactory
creates protocol objects from transports- serviceName
For server stats, (default: "thrift")
- maxThriftBufferSize
The max size of a reusable buffer for the thrift response
- serverStats
StatsReceiver for recording metrics
- responseClassifier
- perEndpointStats
Whether to record per-endpoint stats, (default: false). By enabling this, the specific Thrift Exceptions can be recorded. See PerEndpoint StatsFilter
- class SeqIdFilter extends SimpleFilter[ThriftClientRequest, Array[Byte]]
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.- Note
This only works when using BinaryProtocol.
- case class SeqMismatchException(id: Int, expected: Int) extends TransportException with Product with Serializable
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.
- final class ServerToReqRep extends (Array[Byte]) => ReqRep
Used by Thrift and ThriftMux Server to facilitate giving the Finagle stack access to the deserialized forms of Thrift requests and responses.
Used by Thrift and ThriftMux Server to facilitate giving the Finagle stack access to the deserialized forms of Thrift requests and responses.
While this is thread-safe, it should only be used for the life of a single request/response pair.
When using Scrooge for code generation, a proper
ServerToReqRep
will be available to code viaContexts.local(ServerToReqRep.Key)
. - final class TBufInputTransport extends TTransport
A TTransport that's backed by a Buf.
A TTransport that's backed by a Buf.
We assume that the
input
is "owned", and will directly access the underlying byte array if possible for performance. If theinput
is needded intact, please instead copy theBuf
and then provide it.Note that this class is not threadsafe. If you wish to use it across threads, you must provide your own synchronization.
- trait ThriftClient extends AnyRef
Stateless helper methods which wrap a given
ServiceIface
(deprecated) or a givenServicePerEndpoint
with another type via the given method's implicit Builder. - class ThriftClientRequest extends AnyRef
Defines a (framed) thrift request, simply composed of the raw message and a boolean indicating whether it is a one-shot message or not.
- case class ThriftMethodStats extends Product with Serializable
- trait ThriftRichClient extends AnyRef
A mixin trait to provide a rich Thrift client API.
- trait ThriftRichServer extends AnyRef
A mixin trait to provide a rich Thrift server API.
- trait ThriftService extends AnyRef
A marker trait that signifies that this is a thrift service that can be served by Finagle
- trait ToThriftService extends AnyRef
A trait that signifies a
ThriftService
can be created from this - class ValidateThriftService extends ServiceProxy[ThriftClientRequest, Array[Byte]]
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
.
Deprecated Type Members
- final class DeserializeCtx[Rep] extends ClientDeserializeCtx[Rep]
- Annotations
- @deprecated
- Deprecated
(Since version 2018-8-13) Use ClientDeserializeCtx.
- trait ServiceIfaceBuilder[ServiceIface <: Filterable[ServiceIface]] extends AnyRef
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.
- Annotations
- @deprecated
- Deprecated
(Since version 2017-11-13) Use com.twitter.finagle.thrift.service.ServicePerEndpointBuilder
Value Members
- object ClientDeserializeCtx
- object ClientFunction
- object ClientId extends Serializable
ClientId
provides the client identification of the incoming request if available.ClientId
provides the client identification of the incoming request if available. It is set at the beginning of the request and is available throughout the life-cycle of the request. It is iff the client has an upgraded finagle connection and has chosen to specify the client ID in their codec. - object Headers
- object InputBuffers
- object MethodMetadata
A com.twitter.finagle.context.LocalContext Key for a stored com.twitter.finagle.thrift.MethodMetadata along with an accessor method for retrieving the currently set value.
- object Protocols
- object RichClientParam extends Serializable
- object SeqIdFilter
- object ServerAnnotations
- object ServerToReqRep
- object ThriftMethodStats extends Serializable
- object maxReusableBufferSize extends GlobalFlag[StorageUnit]
Deprecated Value Members
- object DeserializeCtx
- Annotations
- @deprecated
- Deprecated
(Since version 2018-8-13) Use ClientDeserializeCtx.