Package

com.twitter.finagle

thrift

Permalink

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. class ClientIdRequiredFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    Permalink

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

  2. class DeserializeCtx[Rep] extends AnyRef

    Permalink

    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.

  3. case class InvalidThriftConnectionException() extends Exception with ServiceException with Product with Serializable

    Permalink

    Indicates that the connection on which a Thrift request was issued is invalid, where "validity" is determined by com.twitter.finagle.thrift.ValidateThriftService.

  4. trait MethodIfaceBuilder[ServiceIface, MethodIface] extends AnyRef

    Permalink

    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.

  5. class NoClientIdSpecifiedException extends RequestException

    Permalink

    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.

  6. case class RichClientParam(protocolFactory: TProtocolFactory = Thrift.param.protocolFactory, serviceName: String = "", maxThriftBufferSize: Int = Thrift.param.maxThriftBufferSize, responseClassifier: ResponseClassifier = ResponseClassifier.Default, clientStats: StatsReceiver = ClientStatsReceiver) extends Product with Serializable

    Permalink

    Produce a client with params wrapped in RichClientParam

    Produce a client with params wrapped in RichClientParam

    protocolFactory

    A TProtocolFactory creates protocol objects from transports

    serviceName

    For client stats, (default: empty string)

    maxThriftBufferSize

    The max size of a reusable buffer for the thrift response

    responseClassifier

    See com.twitter.finagle.service.ResponseClassifier

    clientStats

    StatsReceiver for recording metrics

  7. case class RichServerParam(protocolFactory: TProtocolFactory = Thrift.param.protocolFactory, serviceName: String = "thrift", maxThriftBufferSize: Int = Thrift.param.maxThriftBufferSize, serverStats: StatsReceiver = LoadedStatsReceiver, responseClassifier: ResponseClassifier = ResponseClassifier.Default) extends Product with Serializable

    Permalink

    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

  8. class SeqIdFilter extends SimpleFilter[ThriftClientRequest, Array[Byte]]

    Permalink

    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.

  9. case class SeqMismatchException(id: Int, expected: Int) extends TransportException with Product with Serializable

    Permalink

    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.

  10. trait ServiceIfaceBuilder[ServiceIface <: Filterable[ServiceIface]] extends AnyRef

    Permalink

    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.

  11. class ThriftClientRequest extends AnyRef

    Permalink
  12. case class ThriftMethodStats(requestsCounter: Counter, successCounter: Counter, failuresCounter: Counter, failuresScope: StatsReceiver) extends Product with Serializable

    Permalink
  13. class ValidateThriftService extends ServiceProxy[ThriftClientRequest, Array[Byte]]

    Permalink

    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.

Value Members

  1. object DeserializeCtx

    Permalink
  2. object InputBuffers

    Permalink
  3. object Protocols

    Permalink
  4. object SeqIdFilter

    Permalink
  5. object ThriftMethodStats extends Serializable

    Permalink
  6. object ThriftServiceIface

    Permalink

    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.

  7. object maxReusableBufferSize extends GlobalFlag[StorageUnit]

    Permalink
  8. package service

    Permalink
  9. package thrift

    Permalink
  10. package thriftscala

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped