Packages

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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. thrift
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait AbstractThriftService extends AnyRef

    A marker trait indicating that a service extending it was generated by Scrooge, targeting Java.

  2. 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 via Contexts.local(ClientDeserializeCtx.Key).

    Note

    this class has evolved and it's name is now a bit too specific for its more expanded role.

  3. class ClientIdRequiredFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A Filter for Thrift services that enforces all requests specify a com.twitter.finagle.thrift.ClientId.

  4. abstract class GeneratedThriftService extends AnyRef

    An abstract class that all scrooge-generated thrift service objects inherit directly from, including services that extend other services.

  5. 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.

  6. 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.

    See also

    com.twitter.finagle.thrift.MethodMetadata.current

  7. 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.

  8. class RichClientParam extends AnyRef

    Thrift-specific parameters for configuring clients.

  9. 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

    See com.twitter.finagle.service.ResponseClassifier

    perEndpointStats

    Whether to record per-endpoint stats, (default: false). By enabling this, the specific Thrift Exceptions can be recorded. See PerEndpoint StatsFilter

  10. 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.

  11. 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.

  12. 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 via Contexts.local(ServerToReqRep.Key).

  13. trait ThriftClient extends AnyRef

    Stateless helper methods which wrap a given ServiceIface (deprecated) or a given ServicePerEndpoint with another type via the given method's implicit Builder.

  14. 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.

  15. case class ThriftMethodStats extends Product with Serializable
  16. trait ThriftRichClient extends AnyRef

    A mixin trait to provide a rich Thrift client API.

  17. trait ThriftRichServer extends AnyRef

    A mixin trait to provide a rich Thrift server API.

  18. trait ThriftService extends AnyRef

    A marker trait that signifies that this is a thrift service that can be served by Finagle

  19. trait ToThriftService extends AnyRef

    A trait that signifies a ThriftService can be created from this

  20. 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.

  21. final class DeserializeCtx[Rep] extends ClientDeserializeCtx[Rep]
    Annotations
    @deprecated
    Deprecated

    (Since version 2018-8-13) Use ClientDeserializeCtx.

  22. trait MethodIfaceBuilder[ServiceIface, MethodIface] extends AnyRef

    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.

    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-13) Use com.twitter.finagle.thrift.service.MethodPerEndpointBuilder

  23. 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

  1. object ClientDeserializeCtx
  2. object Headers
  3. object InputBuffers
  4. 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.

  5. object Protocols
  6. object RichClientParam
  7. object SeqIdFilter
  8. object ServerToReqRep
  9. object ThriftMethodStats extends Serializable
  10. object maxReusableBufferSize extends GlobalFlag[StorageUnit]

Deprecated Value Members

  1. object DeserializeCtx
    Annotations
    @deprecated
    Deprecated

    (Since version 2018-8-13) Use ClientDeserializeCtx.

Inherited from AnyRef

Inherited from Any

Ungrouped