Object

com.twitter.finagle

Thrift

Related Doc: package finagle

Permalink

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)
})
Linear Supertypes
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 = Client.params) extends StdStackClient[ThriftClientRequest, Array[Byte], Client] with WithSessionPool[Client] with WithDefaultLoadBalancer[Client] with WithThriftPartitioningStrategy[Client] with ThriftRichClient with Product with Serializable

    Permalink

    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 = Server.params) extends StdStackServer[Array[Byte], Array[Byte], Server] with ThriftRichServer with Product with Serializable

    Permalink

    A ThriftMux com.twitter.finagle.Server.

    A ThriftMux com.twitter.finagle.Server.

    See also

    Thrift documentation

    Configuration documentation

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. object Client extends ThriftClient with Serializable

    Permalink
  5. object Server extends Serializable

    Permalink
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def client: Client

    Permalink
  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def newClient(dest: Name, label: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

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

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

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

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

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

    Permalink
    Definition Classes
    Client
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. object param

    Permalink
  25. def serve(addr: SocketAddress, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Permalink
    Definition Classes
    Thrift → Server
  26. final def serve(addr: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer

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

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

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

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

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

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

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

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

    Permalink
    Definition Classes
    Server
  35. def server: Server

    Permalink
  36. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  37. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  38. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

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

Inherited from AnyRef

Inherited from Any

Ungrouped