Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package twitter
    Definition Classes
    com
  • package finagle
    Definition Classes
    twitter
  • object Thrift extends Client[ThriftClientRequest, Array[Byte]] with Server[Array[Byte], Array[Byte]]

    Client and server for Apache Thrift.

    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)
    })
    Definition Classes
    finagle
  • Client
  • Server
  • param

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

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Server
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. ThriftRichServer
  7. StdStackServer
  8. ListeningStackServer
  9. WithServerAdmissionControl
  10. WithServerSession
  11. WithServerTransport
  12. CommonParams
  13. StackServer
  14. StackBasedServer
  15. Transformable
  16. Parameterized
  17. Server
  18. AnyRef
  19. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Server(stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]] = Server.stack, params: Params = Server.params)

Type Members

  1. type Context = TransportContext
    Attributes
    protected
    Definition Classes
    Server → StdStackServer
  2. type In = Array[Byte]
    Attributes
    protected
    Definition Classes
    Server → StdStackServer
  3. type Out = Array[Byte]
    Attributes
    protected
    Definition Classes
    Server → StdStackServer

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 addServerToRegistry(listenerName: String): Unit
    Attributes
    protected
    Definition Classes
    ListeningStackServer
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. def configured[P](psp: (P, Param[P])): Server
    Definition Classes
    Server → ListeningStackServer → StackServer → Parameterized
  8. def configured[P](p: P)(implicit arg0: Param[P]): Server
    Definition Classes
    ListeningStackServer → StackServer → Parameterized
  9. def configuredParams(newParams: Params): Server
    Definition Classes
    ListeningStackServer → StackServer → Parameterized
  10. def copy1(stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]] = this.stack, params: Params = this.params): Server
    Attributes
    protected
    Definition Classes
    Server → ListeningStackServer
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. def maxThriftBufferSize: Int
    Attributes
    protected
    Definition Classes
    ThriftRichServer
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def newDispatcher(transport: Transport[In, Out] { type Context <: Server.this.Context }, service: Service[Array[Byte], Array[Byte]]): Closable
    Attributes
    protected
    Definition Classes
    Server → StdStackServer
  18. def newListener(): Listener[In, Out, Context]
    Attributes
    protected
    Definition Classes
    Server → StdStackServer
  19. final def newListeningServer(serviceFactory: ServiceFactory[Array[Byte], Array[Byte]], addr: SocketAddress)(trackSession: (ClientConnection) ⇒ Unit): ListeningServer
    Attributes
    protected
    Definition Classes
    StdStackServer → ListeningStackServer
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. val params: Params
    Definition Classes
    ServerThriftRichServer → StackServer → Parameterized
  23. def serve(addr: SocketAddress, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server → ListeningStackServer → Server
  24. final def serve(addr: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  25. final def serve(addr: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  26. final def serve(addr: SocketAddress, service: Service[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  27. def serveAndAnnounce(name: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  28. def serveAndAnnounce(name: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  29. def serveAndAnnounce(name: String, addr: String, service: Service[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  30. def serveAndAnnounce(name: String, addr: String, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  31. def serveAndAnnounce(name: String, addr: SocketAddress, service: Service[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  32. def serveAndAnnounce(name: String, addr: SocketAddress, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer
    Definition Classes
    Server
  33. def serveIface(addr: SocketAddress, iface: AnyRef): ListeningServer

    Serve the interface implementation iface, which must be generated by either Scrooge or thrift-finagle.

    Serve the interface implementation iface, which must be generated by either Scrooge or thrift-finagle.

    Given the IDL:

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

    Scrooge will generate an interface, TestService.FutureIface, implementing the above IDL.

    TestService.FutureIface must be implemented and passed into serveIface:

    ThriftMuxRichServer
    .serveIface(":*", new TestService.FutureIface {
      def query(x: String) = Future.value(x)  // (echo service)
    })

    Note that this interface is discovered by reflection. Passing an invalid interface implementation will result in a runtime error.

    Definition Classes
    ThriftRichServer
  34. def serveIface(addr: String, iface: AnyRef): ListeningServer

    Serve the interface implementation iface, which must be generated by either Scrooge or thrift-finagle.

    Serve the interface implementation iface, which must be generated by either Scrooge or thrift-finagle.

    Given the IDL:

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

    Scrooge will generate an interface, TestService.FutureIface, implementing the above IDL.

    TestService.FutureIface must be implemented and passed into serveIface:

    ThriftMuxRichServer
    .serveIface(":*", new TestService.FutureIface {
      def query(x: String) = Future.value(x)  // (echo service)
    })

    Note that this interface is discovered by reflection. Passing an invalid interface implementation will result in a runtime error.

    Definition Classes
    ThriftRichServer
  35. def serveIfaces(addr: SocketAddress, ifaces: Map[String, AnyRef], defaultService: Option[String]): ListeningServer

    Serve multiple interfaces:

    Serve multiple interfaces:

    val serviceMap = Map(
    "echo" -> new EchoService(),
    "extendedEcho" -> new ExtendedEchoService()
    )
    
    val server = Thrift.server.serveIfaces(address, serviceMap)

    A default service name can be specified, so we can upgrade an existing non-multiplexed server to a multiplexed one without breaking the old clients:

    val server = Thrift.server.serveIfaces(
      address, serviceMap, defaultService = Some("extendedEcho"))
    Definition Classes
    ThriftRichServer
  36. def serveIfaces(addr: SocketAddress, ifaces: Map[String, AnyRef]): ListeningServer

    Serve multiple interfaces:

    Serve multiple interfaces:

    val serviceMap = Map(
    "echo" -> new EchoService(),
    "extendedEcho" -> new ExtendedEchoService()
    )
    
    val server = Thrift.server.serveIfaces(address, serviceMap)

    A default service name can be specified, so we can upgrade an existing non-multiplexed server to a multiplexed one without breaking the old clients:

    val server = Thrift.server.serveIfaces(
      address, serviceMap, defaultService = Some("extendedEcho"))
    Definition Classes
    ThriftRichServer
  37. def serveIfaces(addr: String, ifaces: Map[String, AnyRef], defaultService: Option[String] = None): ListeningServer

    Serve multiple interfaces:

    Serve multiple interfaces:

    val serviceMap = Map(
    "echo" -> new EchoService(),
    "extendedEcho" -> new ExtendedEchoService()
    )
    
    val server = Thrift.server.serveIfaces(address, serviceMap)

    A default service name can be specified, so we can upgrade an existing non-multiplexed server to a multiplexed one without breaking the old clients:

    val server = Thrift.server.serveIfaces(
      address, serviceMap, defaultService = Some("extendedEcho"))
    Definition Classes
    ThriftRichServer
  38. def serverLabel: String
    Attributes
    protected
    Definition Classes
    ThriftRichServer
  39. val serverParam: RichServerParam
    Attributes
    protected
    Definition Classes
    ServerThriftRichServer
  40. def serverStats: StatsReceiver
    Attributes
    protected
    Definition Classes
    ThriftRichServer
  41. val stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]]
    Definition Classes
    Server → StackServer
  42. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  43. def transformed(t: Transformer): Server
    Definition Classes
    ListeningStackServer → StackServer → Transformable
  44. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  47. val withAdmissionControl: ServerAdmissionControlParams[Server]
    Definition Classes
    Server → WithServerAdmissionControl
  48. def withBufferedTransport(): Server
  49. def withExceptionStatsHandler(exceptionStatsHandler: ExceptionStatsHandler): Server
    Definition Classes
    Server → CommonParams
  50. def withExecutionOffloaded(pool: FuturePool): Server
    Definition Classes
    Server → CommonParams
  51. def withExecutionOffloaded(executor: ExecutorService): Server
    Definition Classes
    Server → CommonParams
  52. def withLabel(label: String): Server
    Definition Classes
    Server → CommonParams
  53. def withLabels(keywords: String*): Server
    Definition Classes
    CommonParams
  54. def withMaxReusableBufferSize(size: Int): Server

    Produce a com.twitter.finagle.Thrift.Server with the specified max size of the reusable buffer for thrift responses.

    Produce a com.twitter.finagle.Thrift.Server with the specified max size of the reusable buffer for thrift responses. If this size is exceeded, the buffer is not reused and a new buffer is allocated for the next thrift response. The default max size is 16Kb.

    size

    Max size of the reusable buffer for thrift responses in bytes.

  55. def withMonitor(monitor: Monitor): Server
    Definition Classes
    Server → CommonParams
  56. def withParams(params: Params): Server
    Definition Classes
    ListeningStackServer → StackServer → Parameterized
  57. def withPerEndpointStats: Server

    Produce a com.twitter.finagle.Thrift.Server with per-endpoint stats filters

  58. def withProtocolFactory(protocolFactory: TProtocolFactory): Server
  59. def withRequestTimeout(timeout: Duration): Server
    Definition Classes
    Server → CommonParams
  60. def withRequestTimeout(timeout: Tunable[Duration]): Server
    Definition Classes
    CommonParams
  61. def withResponseClassifier(responseClassifier: ResponseClassifier): Server
    Definition Classes
    CommonParams
  62. val withSession: ServerSessionParams[Server]
    Definition Classes
    Server → WithServerSession
  63. def withStack(fn: (Stack[ServiceFactory[Array[Byte], Array[Byte]]]) ⇒ Stack[ServiceFactory[Array[Byte], Array[Byte]]]): Server
    Definition Classes
    Server → ListeningStackServer → StackServer
  64. def withStack(stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]]): Server
    Definition Classes
    Server → ListeningStackServer → StackServer
  65. def withStatsReceiver(statsReceiver: StatsReceiver): Server
    Definition Classes
    Server → CommonParams
  66. def withTracer(tracer: Tracer): Server
    Definition Classes
    Server → CommonParams
  67. val withTransport: ServerTransportParams[Server]
    Definition Classes
    Server → WithServerTransport

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from ThriftRichServer

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

Inherited from WithServerSession[Server]

Inherited from WithServerTransport[Server]

Inherited from CommonParams[Server]

Inherited from StackServer[Array[Byte], Array[Byte]]

Inherited from StackBasedServer[Array[Byte], Array[Byte]]

Inherited from Transformable[Server]

Inherited from Parameterized[Server]

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

Inherited from AnyRef

Inherited from Any

Ungrouped