Packages

object Thrift extends Client[ThriftClientRequest, Array[Byte]] with Server[Array[Byte], Array[Byte]]

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 with withProtocolFactory. 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 here.

Clients

Clients can be created directly from an interface generated from a Thrift IDL:

For example, this IDL:

service TestService {
  string query(1: string x)
}

compiled with Scrooge, generates the interface TestService.FutureIface. This is then passed into Thrift.Client.newIface:

Thrift.client.newIface[TestService.FutureIface](
  addr, classOf[TestService.FutureIface])

However note that the Scala compiler can insert the latter Class for us, for which another variant of newIface is provided:

Thrift.client.newIface[TestService.FutureIface](addr)

In Java, we need to provide the class object:

TestService.FutureIface client =
  Thrift.client.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 into serveIface:

// An echo service
ThriftMux.server.serveIface(":*", new TestService.FutureIface {
  def query(x: String): Future[String] = Future.value(x)
})
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Thrift
  2. Server
  3. Client
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class Client (stack: Stack[ServiceFactory[ThriftClientRequest, Array[Byte]]] = Client.stack, params: Params = ...) extends StdStackClient[ThriftClientRequest, Array[Byte], Client] with WithSessionPool[Client] with WithDefaultLoadBalancer[Client] with ThriftRichClient with Product with Serializable

    A ThriftMux com.twitter.finagle.Client.

    A ThriftMux com.twitter.finagle.Client.

    See also

    Mux documentation

    Thrift documentation

    Configuration documentation

  2. case class Server (stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]] = Server.stack, params: Params = ...) extends StdStackServer[Array[Byte], Array[Byte], Server] with ThriftRichServer with Product with Serializable

    A ThriftMux com.twitter.finagle.Server.

    A ThriftMux com.twitter.finagle.Server.

    See also

    Thrift documentation

    Configuration documentation

  3. case class ThriftImpl (transporter: (Params) ⇒ (SocketAddress) ⇒ Transporter[ThriftClientRequest, Array[Byte]], listener: (Params) ⇒ Listener[Array[Byte], Array[Byte]]) extends Product with Serializable

    The vanilla Thrift Transporter and Listener factories deviate from other protocols in the result of the netty pipeline: most other protocols expect to receive a framed Buf while vanilla thrift produces an Array[Byte].

    The vanilla Thrift Transporter and Listener factories deviate from other protocols in the result of the netty pipeline: most other protocols expect to receive a framed Buf while vanilla thrift produces an Array[Byte]. This has two related motivations. First, the end result needed by the thrift implementations is an Array[Byte], which is relatively trivial to deal with and is a JVM native type so it's unnecessary to go through a Buf. By avoiding an indirection through Buf we can avoid an unnecessary copy in the netty4 pipeline that would be required to ensure that the bytes were on the heap before entering the Finagle transport types.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. val client: Client
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. val maxThriftBufferSize: Int
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def newClient(dest: Name, label: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

    Create a new client connected to dest.

    Create a new client connected to dest. See the user guide for details on destination names.

    Argument label is used to assign a label to this client. The label is used to display stats, etc.

    Definition Classes
    ThriftClient
  16. final def newClient(dest: String, label: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

    Create a new client connected to dest.

    Create a new client connected to dest. See the user guide for details on destination names.

    Argument label is used to assign a label to this client. The label is used to display stats, etc.

    Definition Classes
    Client
  17. final def newClient(dest: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

    Create a new client connected to dest.

    Create a new client connected to dest. See the user guide for details on destination names.

    Definition Classes
    Client
  18. def newService(dest: Name, label: String): Service[ThriftClientRequest, Array[Byte]]

    Create a new service which dispatches requests to dest.

    Create a new service which dispatches requests to dest. See the user guide for details on destination names.

    Argument label is used to assign a label to this client. The label is used to display stats, etc.

    Definition Classes
    ThriftClient
  19. final def newService(dest: String, label: String): Service[ThriftClientRequest, Array[Byte]]

    Create a new service which dispatches requests to dest.

    Create a new service which dispatches requests to dest. See the user guide for details on destination names.

    Definition Classes
    Client
  20. final def newService(dest: String): Service[ThriftClientRequest, Array[Byte]]

    Create a new service which dispatches requests to dest.

    Create a new service which dispatches requests to dest. See the user guide for details on destination names.

    Definition Classes
    Client
  21. final def notify(): Unit
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  23. val protocolFactory: TProtocolFactory
  24. def serve(addr: SocketAddress, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    ThriftServer
  25. def serve(addr: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  26. def serve(addr: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  27. def serve(addr: SocketAddress, service: Service[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  28. def serveAndAnnounce(name: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr and announce with name.

    Serve service at addr and announce with name. Announcements will be removed when the service is closed. Omitting the addr will bind to an ephemeral port.

    Definition Classes
    Server
  29. def serveAndAnnounce(name: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr and announce with name.

    Serve service at addr and announce with name. Announcements will be removed when the service is closed. Omitting the addr will bind to an ephemeral port.

    Definition Classes
    Server
  30. def serveAndAnnounce(name: String, addr: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr and announce with name.

    Serve service at addr and announce with name. Announcements will be removed when the service is closed. Omitting the addr will bind to an ephemeral port.

    Definition Classes
    Server
  31. def serveAndAnnounce(name: String, addr: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr and announce with name.

    Serve service at addr and announce with name. Announcements will be removed when the service is closed. Omitting the addr will bind to an ephemeral port.

    Definition Classes
    Server
  32. def serveAndAnnounce(name: String, addr: SocketAddress, service: Service[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr and announce with name.

    Serve service at addr and announce with name. Announcements will be removed when the service is closed. Omitting the addr will bind to an ephemeral port.

    Definition Classes
    Server
  33. def serveAndAnnounce(name: String, addr: SocketAddress, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr and announce with name.

    Serve service at addr and announce with name. Announcements will be removed when the service is closed. Omitting the addr will bind to an ephemeral port.

    Definition Classes
    Server
  34. val server: Server
  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. object Client extends Serializable
  41. object Server extends Serializable
  42. object ThriftImpl extends Serializable
  43. object param

Deprecated Value Members

  1. final def newClient(dest: Group[SocketAddress]): ServiceFactory[ThriftClientRequest, Array[Byte]]
    Definition Classes
    Client
    Annotations
    @deprecated
    Deprecated

    (Since version 6.7.x) Use destination names

  2. final def newService(dest: Group[SocketAddress]): Service[ThriftClientRequest, Array[Byte]]
    Definition Classes
    Client
    Annotations
    @deprecated
    Deprecated

    (Since version 6.7.x) Use destination names

  3. def withClientId(clientId: ClientId): Client
    Annotations
    @deprecated
    Deprecated

    (Since version 6.22.0) Use Thrift.client.withClientId

  4. def withProtocolFactory(protocolFactory: TProtocolFactory): Client
    Annotations
    @deprecated
    Deprecated

    (Since version 6.22.0) Use Thrift.client.withProtocolFactory

Inherited from finagle.Server[Array[Byte], Array[Byte]]

Inherited from AnyRef

Inherited from Any

Ungrouped