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 Http extends Client[Request, Response] with HttpRichClient with Server[Request, Response]

    HTTP/1.1 protocol support, including client and server.

    HTTP/1.1 protocol support, including client and server.

    Definition Classes
    finagle
  • Client
  • HttpImpl
  • Server

case class Server(stack: Stack[ServiceFactory[Request, Response]] = Server.stack, params: Params = Server.params) extends StdStackServer[Request, Response, Server] with Product with Serializable

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

Instance Constructors

  1. new Server(stack: Stack[ServiceFactory[Request, Response]] = 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 = Any

    The type we write into the transport.

    The type we write into the transport.

    Attributes
    protected
    Definition Classes
    ServerStdStackServer
  3. type Out = Any

    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 asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. 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
  7. 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
  8. def configuredParams(newParams: Params): Server

    Creates a new StackServer with additional parameters newParams.

    Creates a new StackServer with additional parameters newParams.

    Definition Classes
    ServerListeningStackServerStackServerParameterized
  9. def copy1(stack: Stack[ServiceFactory[Request, Response]] = 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
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def newDispatcher(transport: Transport[In, Out] { type Context <: Server.this.Context }, service: Service[Request, Response]): HttpServerDispatcher

    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

  16. def newListener(): Listener[Any, Any, TransportContext]

    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
  17. final def newListeningServer(serviceFactory: ServiceFactory[Request, Response], 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
  18. def newStreamTransport(transport: Transport[Any, Any]): StreamTransport[Response, Request]
    Attributes
    protected
  19. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. val params: Params
    Definition Classes
    ServerStackServerParameterized
  22. def serve(addr: SocketAddress, factory: ServiceFactory[Request, Response]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    ServerListeningStackServerServer
  23. final def serve(addr: String, service: Service[Request, Response]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  24. final def serve(addr: String, service: ServiceFactory[Request, Response]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  25. final def serve(addr: SocketAddress, service: Service[Request, Response]): ListeningServer

    Serve service at addr

    Serve service at addr

    Definition Classes
    Server
  26. def serveAndAnnounce(name: String, service: Service[Request, Response]): 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
  27. def serveAndAnnounce(name: String, service: ServiceFactory[Request, Response]): 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
  28. def serveAndAnnounce(name: String, addr: String, service: Service[Request, Response]): 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, addr: String, service: ServiceFactory[Request, Response]): 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: SocketAddress, service: Service[Request, Response]): 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: SocketAddress, service: ServiceFactory[Request, Response]): 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. val stack: Stack[ServiceFactory[Request, Response]]
    Definition Classes
    ServerStackServer
  33. def superServe(addr: SocketAddress, factory: ServiceFactory[Request, Response]): ListeningServer
    Attributes
    protected
  34. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  35. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  38. val withAdmissionControl: ServerAdmissionControlParams[Server]
    Definition Classes
    ServerWithServerAdmissionControl
  39. def withCompressionLevel(level: Int): Server

    The compression level to use.

    The compression level to use. If passed the default value (-1) then it will use TextualContentCompressor which will compress text-like content-types with the default compression level (6). Otherwise, use the Netty HttpContentCompressor for all content-types with specified compression level.

  40. def withDecompression(enabled: Boolean): Server

    Enables decompression of http content bodies.

  41. 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
  42. def withHttpStats: Server

    Enable the collection of HTTP specific metrics.

    Enable the collection of HTTP specific metrics. See http.filter.StatsFilter.

  43. 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
  44. def withMaxHeaderSize(size: StorageUnit): Server

    For HTTP1*, configures the max size of headers For HTTP2, sets the MAX_HEADER_LIST_SIZE setting which is the maximum number of uncompressed bytes of header name/values.

    For HTTP1*, configures the max size of headers For HTTP2, sets the MAX_HEADER_LIST_SIZE setting which is the maximum number of uncompressed bytes of header name/values. These may be set independently via the .configured API.

  45. def withMaxInitialLineSize(size: StorageUnit): Server

    Configures the maximum initial http line length the server is willing to accept.

  46. def withMaxRequestSize(size: StorageUnit): Server

    Configures the maximum request size this server can receive.

  47. def withMaxResponseSize(size: StorageUnit): Server

    Configures the maximum response size this server can send.

  48. 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).

    Definition Classes
    ServerCommonParams
  49. def withNoAutomaticContinue: Server

    By default finagle-http automatically sends 100-CONTINUE responses to inbound requests which set the 'Expect: 100-Continue' header.

    By default finagle-http automatically sends 100-CONTINUE responses to inbound requests which set the 'Expect: 100-Continue' header. Streaming servers will always return 100-CONTINUE. Non-streaming servers will compare the content-length header to the configured limit (see: withMaxRequestSize) and send either a 100-CONTINUE or 413-REQUEST ENTITY TOO LARGE as appropriate. This method disables those automatic responses.

    Note

    Disabling automatic continues is only supported in com.twitter.finagle.Http.Netty4Impl servers.

    ,

    Servers operating as proxies should disable automatic responses in order to allow origin servers to determine whether the expectation can be met.

  50. 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
  51. 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

  52. 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

  53. 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
    ServerCommonParams
    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.

  54. val withSession: SessionParams[Server]
    Definition Classes
    ServerWithServerSession
  55. def withStack(stack: Stack[ServiceFactory[Request, Response]]): Server

    A new StackServer with the provided Stack.

    A new StackServer with the provided Stack.

    Definition Classes
    ServerListeningStackServerStackServer
  56. 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
  57. def withStreaming(enabled: Boolean): Server

    Streaming allows applications to work with HTTP messages that have large (or infinite) content bodies.

    Streaming allows applications to work with HTTP messages that have large (or infinite) content bodies. When this set to true, the message content is available through a com.twitter.io.Reader, which gives the application a handle to the byte stream. If false, the entire message content is buffered into a com.twitter.io.Buf.

  58. 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
  59. val withTransport: ServerTransportParams[Server]
    Definition Classes
    ServerWithServerTransport

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from WithServerSession[Server]

Inherited from WithServerTransport[Server]

Inherited from CommonParams[Server]

Inherited from StackServer[Request, Response]

Inherited from StackBasedServer[Request, Response]

Inherited from Parameterized[Server]

Inherited from finagle.Server[Request, Response]

Inherited from AnyRef

Inherited from Any

Ungrouped