com.twitter.finagle

Thrift

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

Client and server for Apache Thrift. Thrift implements Thrift framed transport and binary protocol by default, though custom protocol factories may be injected with withProtocolFactory. The client, Client[ThriftClientRequest, Array[Byte]] provides direct access to the thrift transport, but we recommend using code generation though either Scrooge or a fork of the Apache generator. A rich API is provided to support interfaces generated with either of these code generators.

Clients

For example, this IDL:

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

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

Thrift.newIface[TestService.FutureIface](
target, 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.newIface[TestService.FutureIface](target)

In Java, we need to provide the class object:

TestService.FutureIface client =
Thrift.newIface(target, 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:

Thrift.serveIface(":*", new TestService.FutureIface {
  def query(x: String) = Future.value(x)  // (echo service)
})
Linear Supertypes
ThriftRichServer, ThriftRichClient, Server[Array[Byte], Array[Byte]], Client[ThriftClientRequest, Array[Byte]], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Thrift
  2. ThriftRichServer
  3. ThriftRichClient
  4. Server
  5. Client
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  8. val defaultClientName: String

    The client name used when group isn't named.

    The client name used when group isn't named.

    Attributes
    protected
    Definition Classes
    ThriftThriftRichClient
  9. final def eq(arg0: AnyRef): Boolean

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

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

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

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

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

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

    Definition Classes
    AnyRef
  16. def newClient(group: Group[SocketAddress]): ServiceFactory[ThriftClientRequest, Array[Byte]]

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

    Definition Classes
    Client
  18. def newIface[Iface](group: Group[SocketAddress])(implicit arg0: ClassManifest[Iface]): Iface

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Definition Classes
    ThriftRichClient
  19. def newIface[Iface](target: String)(implicit arg0: ClassManifest[Iface]): Iface

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Definition Classes
    ThriftRichClient
  20. def newIface[Iface](group: Group[SocketAddress], cls: Class[_]): Iface

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Definition Classes
    ThriftRichClient
  21. def newIface[Iface](target: String, cls: Class[_]): Iface

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Create a new client of type Iface, which must be generated by either Scrooge or thrift-finagle.

    Definition Classes
    ThriftRichClient
  22. final def newService(target: String): Service[ThriftClientRequest, Array[Byte]]

    Definition Classes
    Client
  23. final def newService(group: Group[SocketAddress]): Service[ThriftClientRequest, Array[Byte]]

    Definition Classes
    Client
  24. final def notify(): Unit

    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  26. val protocolFactory: Factory

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

    Definition Classes
    Thrift → Server
  28. def serve(target: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer

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

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

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

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

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

    Definition Classes
    Server
  34. def serveAndAnnounce(forum: String, target: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Definition Classes
    Server
  35. def serveIface(target: SocketAddress, iface: AnyRef): ListeningServer

    $serveIface

    $serveIface

    Definition Classes
    ThriftRichServer
  36. def serveIface(target: String, iface: AnyRef): ListeningServer

    Definition Classes
    ThriftRichServer
  37. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  38. def toString(): String

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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  42. def withBufferedTransport(): ThriftImpl

    Produce a com.twitter.finagle.ThriftImpl using a buffered transport.

    Produce a com.twitter.finagle.ThriftImpl using a buffered transport.

    Note

    Not recommended. Use only if absolutely required for legacy purposes.

  43. def withProtocolFactory(pf: TProtocolFactory): ThriftImpl

    Produce a com.twitter.finagle.ThriftImpl using the given TProtocolFactory instead of the default binary protocol factory.

Inherited from ThriftRichServer

Inherited from ThriftRichClient

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

Inherited from Client[ThriftClientRequest, Array[Byte]]

Inherited from AnyRef

Inherited from Any

Ungrouped