Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package twitter

    Start with com.twitter.finagle.

    Definition Classes
    com
  • package finagle

    Finagle is an extensible RPC system.

    Finagle is an extensible RPC system.

    Services are represented by class com.twitter.finagle.Service. Clients make use of com.twitter.finagle.Service objects while servers implement them.

    Finagle contains a number of protocol implementations; each of these implement Client and/or com.twitter.finagle.Server. For example, Finagle's HTTP implementation, com.twitter.finagle.Http (in package finagle-http), exposes both.

    Thus a simple HTTP server is built like this:

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Await, Future}
    
    val service = new Service[Request, Response] {
      def apply(req: Request): Future[Response] =
        Future.value(Response())
    }
    val server = Http.server.serve(":8080", service)
    Await.ready(server)

    We first define a service to which requests are dispatched. In this case, the service returns immediately with a HTTP 200 OK response, and with no content.

    This service is then served via the Http protocol on TCP port 8080. Finally we wait for the server to stop serving.

    We can now query our web server:

    % curl -D - localhost:8080
    HTTP/1.1 200 OK

    Building an HTTP client is also simple. (Note that type annotations are added for illustration.)

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Future, Return, Throw}
    
    val client: Service[Request, Response] = Http.client.newService("localhost:8080")
    val f: Future[Response] = client(Request()).respond {
      case Return(rep) =>
        printf("Got HTTP response %s\n", rep)
      case Throw(exc) =>
        printf("Got error %s\n", exc)
    }

    Http.client.newService("localhost:8080") constructs a new com.twitter.finagle.Service instance connected to localhost TCP port 8080. We then issue a HTTP/1.1 GET request to URI "/". The service returns a com.twitter.util.Future representing the result of the operation. We listen to this future, printing an appropriate message when the response arrives.

    The Finagle homepage contains useful documentation and resources for using 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.MethodPerEndpoint. This is then passed into Thrift.Client.build:

    Thrift.client.build[TestService.MethodPerEndpoint](
      addr, classOf[TestService.MethodPerEndpoint])

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

    Thrift.client.build[TestService.MethodPerEndpoint](addr)

    In Java, we need to provide the class object:

    TestService.MethodPerEndpoint client =
      Thrift.client.build(addr, TestService.MethodPerEndpoint.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.MethodPerEndpoint must be implemented and passed into serveIface:

    // An echo service
    ThriftMux.server.serveIface(":*", new TestService.MethodPerEndpoint {
      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. Product
  4. Equals
  5. ThriftRichServer
  6. StdStackServer
  7. ListeningStackServer
  8. WithServerAdmissionControl
  9. WithServerSession
  10. WithServerTransport
  11. CommonParams
  12. StackServer
  13. StackBasedServer
  14. Transformable
  15. Parameterized
  16. Server
  17. AnyRef
  18. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

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

Type Members

  1. type Context = TransportContext

    The type of the transport's context.

    The type of the transport's context.

    Attributes
    protected
    Definition Classes
    ServerStdStackServer
  2. type In = Array[Byte]

    The type we write into the transport.

    The type we write into the transport.

    Attributes
    protected
    Definition Classes
    ServerStdStackServer
  3. type Out = Array[Byte]

    The type we read out of the transport.

    The type we read out of the transport.

    Attributes
    protected
    Definition Classes
    ServerStdStackServer

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

    Export info about the listener type to the global registry.

    Export info about the listener type to the global registry.

    The information about its implementation can then be queried at runtime.

    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(classOf[java.lang.CloneNotSupportedException]) @native()
  7. def configured[P](psp: (P, Param[P])): Server

    Creates a new StackServer with parameter psp._1 and Stack Param type psp._2.

    Creates a new StackServer with parameter psp._1 and Stack Param type psp._2.

    Definition Classes
    ServerListeningStackServerStackServerParameterized
  8. def configured[P](p: P)(implicit arg0: Param[P]): Server

    Creates a new StackServer with parameter p.

    Creates a new StackServer with parameter p.

    Definition Classes
    ListeningStackServerStackServerParameterized
  9. def configuredParams(newParams: Params): Server

    Creates a new StackServer with additional parameters newParams.

    Creates a new StackServer with additional parameters newParams.

    Definition Classes
    ListeningStackServerStackServerParameterized
  10. def copy1(stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]] = this.stack, params: Params = this.params): Server

    A copy constructor in lieu of defining StackServer as a case class.

    A copy constructor in lieu of defining StackServer as a case class.

    Attributes
    protected
    Definition Classes
    ServerListeningStackServer
  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[_ <: AnyRef]
    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

    Defines a dispatcher, a function which binds a transport to a com.twitter.finagle.Service.

    Defines a dispatcher, a function which binds a transport to a com.twitter.finagle.Service. Together with a Listener, it forms the foundation of a finagle server. Concrete implementations are expected to specify this.

    Attributes
    protected
    Definition Classes
    ServerStdStackServer
    Note

    The dispatcher must be prepared to handle the situation where it receives an already-closed transport.

    See also

    com.twitter.finagle.dispatch.GenSerialServerDispatcher

  18. def newListener(): Listener[In, Out, Context]

    Defines a typed com.twitter.finagle.server.Listener for this server.

    Defines a typed com.twitter.finagle.server.Listener for this server. Concrete StackServer implementations are expected to specify this.

    Attributes
    protected
    Definition Classes
    ServerStdStackServer
  19. final def newListeningServer(serviceFactory: ServiceFactory[Array[Byte], Array[Byte]], addr: SocketAddress)(trackSession: (ClientConnection) => Unit): ListeningServer

    Constructs a new ListeningServer from the ServiceFactory.

    Constructs a new ListeningServer from the ServiceFactory. Each new session is passed to the trackSession function exactly once to facilitate connection resource management.

    Attributes
    protected
    Definition Classes
    StdStackServerListeningStackServer
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. val params: Params

    The current parameter map used in this StackServer.

    The current parameter map used in this StackServer.

    Definition Classes
    ServerThriftRichServerStackServerParameterized
  23. def productElementNames: Iterator[String]
    Definition Classes
    Product
  24. def serve(addr: SocketAddress, service: ServiceFactory[Array[Byte], Array[Byte]]): ListeningServer

    Serve service at addr

    Serve service at addr

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

    Serve service at addr

    Serve service at addr

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

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  27. final 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. 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.MethodPerEndpoint, implementing the above IDL.

    TestService.MethodPerEndpoint must be implemented and passed into serveIface:

    ThriftMuxRichServer
    .serveIface(":*", new TestService.MethodPerEndpoint {
      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 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.MethodPerEndpoint, implementing the above IDL.

    TestService.MethodPerEndpoint must be implemented and passed into serveIface:

    ThriftMuxRichServer
    .serveIface(":*", new TestService.MethodPerEndpoint {
      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
  36. 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
  37. 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
  38. 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
  39. def serverLabel: String
    Attributes
    protected
    Definition Classes
    ThriftRichServer
  40. val serverParam: RichServerParam
    Attributes
    protected
    Definition Classes
    ServerThriftRichServer
  41. def serverStats: StatsReceiver
    Attributes
    protected
    Definition Classes
    ThriftRichServer
  42. val stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]]

    The current stack used in this StackServer.

    The current stack used in this StackServer.

    Definition Classes
    ServerStackServer
  43. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  44. def transformed(t: Transformer): Server

    Definition Classes
    ListeningStackServerStackServerTransformable
    See also

    withStack

  45. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  46. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  48. val withAdmissionControl: ServerAdmissionControlParams[Server]

    An entry point for configuring the servers' admission control.

    An entry point for configuring the servers' admission control.

    Definition Classes
    ServerWithServerAdmissionControl
  49. def withBufferedTransport(): Server
  50. def withExceptionStatsHandler(exceptionStatsHandler: ExceptionStatsHandler): Server

    Configures this server or client with given exception stats handler.

    Configures this server or client with given exception stats handler.

    Definition Classes
    ServerCommonParams
  51. def withExecutionOffloaded(pool: FuturePool): Server

    Configures this server or client to shift user-defined computation (com.twitter.util.Future callbacks and transformations) off of IO threads into a given FuturePool.

    Configures this server or client to shift user-defined computation (com.twitter.util.Future callbacks and transformations) off of IO threads into a given FuturePool.

    By default, Finagle executes all futures in the IO threads, minimizing context switches. Given there is usually a fixed number of IO threads shared across a JVM process, it's critically important to ensure they aren't being blocked by the application code, affecting system's responsiveness. Shifting application-level work onto a dedicated FuturePool or ExecutorService offloads IO threads, which may improve throughput in CPU-bound systems.

    As always, run your own tests before enabling this feature.

    Definition Classes
    ServerCommonParams
  52. def withExecutionOffloaded(executor: ExecutorService): Server

    Configures this server or client to shift user-defined computation (com.twitter.util.Future callbacks and transformations) off of IO threads into a given ExecutorService.

    Configures this server or client to shift user-defined computation (com.twitter.util.Future callbacks and transformations) off of IO threads into a given ExecutorService.

    By default, Finagle executes all futures in the IO threads, minimizing context switches. Given there is usually a fixed number of IO threads shared across a JVM process, it's critically important to ensure they aren't being blocked by the application code, affecting system's responsiveness. Shifting application-level work onto a dedicated FuturePool or ExecutorService offloads IO threads, which may improve throughput in CPU-bound systems.

    As always, run your own tests before enabling this feature.

    Definition Classes
    ServerCommonParams
  53. def withLabel(label: String): Server

    Configures this server or client with given label (default: empty string).

    Configures this server or client with given label (default: empty string).

    The label value is used for stats reporting to scope stats reported from different clients/servers to a single stats receiver.

    Definition Classes
    ServerCommonParams
  54. def withLabels(keywords: String*): Server
    Definition Classes
    CommonParams
  55. 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.

  56. def withMonitor(monitor: Monitor): Server

    Configures this server or client with given util.Monitor (default: com.twitter.finagle.util.DefaultMonitor).

    Configures this server or client with given util.Monitor (default: com.twitter.finagle.util.DefaultMonitor).

    Monitors are Finagle's out-of-band exception reporters. Whenever an exception is thrown on a request path, it's reported to the monitor. The default monitor implementation, com.twitter.finagle.util.DefaultMonitor, logs these exceptions.

    Monitors are wired into the server or client stacks via com.twitter.finagle.filter.MonitorFilter and are applied to the following kinds of exceptions:

    • Synchronous exceptions thrown on request path, Service.apply(request)
    • Asynchronous exceptions (failed futures) thrown on request path, Service.apply(request)
    • Exceptions thrown from respond, onSuccess, onFailure future callbacks
    • Fatal exceptions thrown from map, flatMap, transform future continuations

    Put it this way, we apply Monitor.handle to an exception if we would otherwise "lose" it, i.e. when it's not connected to the Future, nor is it connected to the call stack.

    You can compose multiple monitors if you want to extend or override the standard behavior, defined in DefaultMonitor.

    import com.twitter.util.Monitor
    
    val consoleMonitor = new Monitor {
      def handle(exc: Throwable): Boolean = {
        Console.err.println(exc.toString)
        false // continue handling with the next monitor (usually DefaultMonitor)
       }
    }
    
    $.withMonitor(consoleMonitor)

    Returning true form within a monitor effectively terminates the monitor chain so no exceptions are propagated down to the next monitor.

    Definition Classes
    ServerCommonParams
  57. def withParams(params: Params): Server

    Creates a new StackServer with params used to configure this StackServer's stack.

    Creates a new StackServer with params used to configure this StackServer's stack.

    Definition Classes
    ListeningStackServerStackServerParameterized
  58. def withPerEndpointStats: Server

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

  59. def withProtocolFactory(protocolFactory: TProtocolFactory): Server
  60. def withRequestTimeout(timeout: Duration): Server

    Configures the request timeout of this server or client (default: unbounded).

    Configures the request timeout of this server or client (default: unbounded).

    If the request has not completed within the given timeout, the pending work will be interrupted via com.twitter.util.Future.raise.

    Client's Request Timeout

    The client request timeout is the maximum amount of time given to a single request (if there are retries, they each get a fresh request timeout). The timeout is applied only after a connection has been acquired. That is: it is applied to the interval between the dispatch of the request and the receipt of the response.

    Server's Request Timeout

    The server request timeout is the maximum amount of time, a server is allowed to spend handling the incoming request. Using the Finagle terminology, this is an amount of time after which a non-satisfied future returned from the user-defined service times out.

    Definition Classes
    ServerCommonParams
    See also

    https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration

  61. def withRequestTimeout(timeout: Tunable[Duration]): Server

    Configures the Tunable request timeout of this server or client (if applying the Tunable produces a value of None, an unbounded timeout is used for the request).

    Configures the Tunable request timeout of this server or client (if applying the Tunable produces a value of None, an unbounded timeout is used for the request).

    If the request has not completed within the Duration resulting from timeout.apply(), the pending work will be interrupted via com.twitter.util.Future.raise.

    Client's Request Timeout

    The client request timeout is the maximum amount of time given to a single request (if there are retries, they each get a fresh request timeout). The timeout is applied only after a connection has been acquired. That is: it is applied to the interval between the dispatch of the request and the receipt of the response.

    Server's Request Timeout

    The server request timeout is the maximum amount of time, a server is allowed to spend handling the incoming request. Using the Finagle terminology, this is an amount of time after which a non-satisfied future returned from the user-defined service times out.

    Definition Classes
    CommonParams
    See also

    https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration and https://twitter.github.io/finagle/guide/Configuration.html#tunables

  62. def withResponseClassifier(responseClassifier: ResponseClassifier): Server

    Configure a com.twitter.finagle.service.ResponseClassifier which is used to determine the result of a request/response.

    Configure a com.twitter.finagle.service.ResponseClassifier which is used to determine the result of a request/response.

    This allows developers to give Finagle the additional application-specific knowledge necessary in order to properly classify responses. Without this, Finagle cannot make judgements about application-level failures as it only has a narrow understanding of failures (for example: transport level, timeouts, and nacks).

    As an example take an HTTP server that returns a response with a 500 status code. To Finagle this is a successful request/response. However, the application developer may want to treat all 500 status codes as failures and can do so via setting a com.twitter.finagle.service.ResponseClassifier.

    ResponseClassifier is a PartialFunction and as such multiple classifiers can be composed together via PartialFunction.orElse.

    Response classification is independently configured on the client and server. For client-side response classification using com.twitter.finagle.builder.ClientBuilder, see com.twitter.finagle.builder.ClientBuilder.responseClassifier

    Definition Classes
    CommonParams
    Note

    If unspecified, the default classifier is com.twitter.finagle.service.ResponseClassifier.Default which is a total function fully covering the input domain.

    See also

    com.twitter.finagle.http.service.HttpResponseClassifier for some HTTP classification tools.

  63. def withServiceClass(clazz: Class[_]): Server

    Configure the service class that may be used with this server to collect instrumentation metadata.

    Configure the service class that may be used with this server to collect instrumentation metadata. This is not necessary to run a service.

    Note

    that when using the .serveIface methods this is unnecessary.

  64. val withSession: ServerSessionParams[Server]

    An entry point for configuring the client's sessions.

    An entry point for configuring the client's sessions.

    Session might be viewed as logical connection that wraps a physical connection (i.e., transport) and controls its lifecycle. Sessions are used in Finagle to maintain liveness, requests cancellation, draining, and many more.

    The default setup for a Finagle server's sessions is to not put any timeouts on it.

    Definition Classes
    ServerWithServerSession
  65. def withStack(fn: (Stack[ServiceFactory[Array[Byte], Array[Byte]]]) => Stack[ServiceFactory[Array[Byte], Array[Byte]]]): Server

    A new StackServer using the function to create a new Stack.

    A new StackServer using the function to create a new Stack.

    The input to fn is the client's current stack. This API allows for easier usage when writing code that uses method chaining.

    This method is similar to transformed while providing easier API ergonomics for one-off Stack changes.

    Definition Classes
    ServerListeningStackServerStackServer
    Example:
    1. From Scala:

      import com.twitter.finagle.Http
      
      Http.server.withStack(_.prepend(MyStackModule))

      From Java:

      import com.twitter.finagle.Http;
      import static com.twitter.util.Function.func;
      
      Http.server().withStack(func(stack -> stack.prepend(MyStackModule)));
    See also

    withStack(Stack)

    transformed

  66. def withStack(stack: Stack[ServiceFactory[Array[Byte], Array[Byte]]]): Server

    A new StackServer with the provided Stack.

    A new StackServer with the provided Stack.

    Definition Classes
    ServerListeningStackServerStackServer
    See also

    withStack that takes a Function1 for a more ergonomic API when used with method chaining.

  67. def withStatsReceiver(statsReceiver: StatsReceiver): Server

    Configures this server or client with given stats.StatsReceiver (default: stats.DefaultStatsReceiver).

    Configures this server or client with given stats.StatsReceiver (default: stats.DefaultStatsReceiver).

    Definition Classes
    ServerCommonParams
  68. def withTracer(tracer: Tracer): Server

    Configures this server or client with given tracing.Tracer (default: com.twitter.finagle.tracing.DefaultTracer).

    Configures this server or client with given tracing.Tracer (default: com.twitter.finagle.tracing.DefaultTracer).

    Definition Classes
    ServerCommonParams
    Note

    if you supply com.twitter.finagle.tracing.NullTracer, no trace information will be written, but this does not disable Finagle from propagating trace information. Instead, if traces are being aggregated across your fleet, it will orphan subsequent spans.

  69. val withTransport: ServerTransportParams[Server]

    An entry point for configuring servers' com.twitter.finagle.transport.Transport.

    An entry point for configuring servers' com.twitter.finagle.transport.Transport.

    Transport is a Finagle abstraction over the network connection (i.e., a TCP connection).

    Definition Classes
    ServerWithServerTransport

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from ThriftRichServer

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