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 Mysql extends Client[Request, Result] with MysqlRichClient

    Definition Classes
    finagle
    Example:
    1. val client = Mysql.client
        .withCredentials("", "")
        .withDatabase("")
        .newRichClient("inet!localhost:3306")
  • Client
  • param

case class Client(stack: Stack[ServiceFactory[Request, Result]] = Client.stack, params: Params = Client.params) extends StdStackClient[Request, Result, Client] with WithSessionPool[Client] with WithDefaultLoadBalancer[Client] with MysqlRichClient with Product with Serializable

Implements a mysql client in terms of a com.twitter.finagle.client.StackClient. The client inherits a wealth of features from finagle including connection pooling and load balancing.

Additionally, this class provides methods for constructing a rich client which exposes a rich mysql api.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Client
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. MysqlRichClient
  7. WithDefaultLoadBalancer
  8. WithSessionPool
  9. StdStackClient
  10. EndpointerStackClient
  11. WithSessionQualifier
  12. WithClientSession
  13. WithClientTransport
  14. WithClientAdmissionControl
  15. ClientParams
  16. CommonParams
  17. StackClient
  18. StackBasedClient
  19. Transformable
  20. Parameterized
  21. Client
  22. AnyRef
  23. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Client(stack: Stack[ServiceFactory[Request, Result]] = Client.stack, params: Params = Client.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
    ClientStdStackClient
  2. type In = Buf

    The type we write into the transport.

    The type we write into the transport.

    Attributes
    protected
    Definition Classes
    ClientStdStackClient
  3. type Out = Buf

    The type we read out of the transport.

    The type we read out of the transport.

    Attributes
    protected
    Definition Classes
    ClientStdStackClient

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])): Client

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

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

    Definition Classes
    ClientEndpointerStackClientStackClientParameterized
  7. def configured[P](p: P)(implicit arg0: Param[P]): Client

    Creates a new StackClient with parameter p.

    Creates a new StackClient with parameter p.

    Definition Classes
    EndpointerStackClientStackClientParameterized
  8. def configuredParams(newParams: Params): Client

    Creates a new StackClient with additional parameters newParams.

    Creates a new StackClient with additional parameters newParams.

    Definition Classes
    EndpointerStackClientStackClientParameterized
  9. def copy1(stack: Stack[ServiceFactory[Request, Result]] = this.stack, params: Params = this.params): Client

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

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

    Attributes
    protected
    Definition Classes
    ClientStdStackClientEndpointerStackClient
  10. final def endpointer: Stackable[ServiceFactory[Request, Result]]

    A stackable module that creates new Transports (via transporter) when applied.

    A stackable module that creates new Transports (via transporter) when applied.

    Attributes
    protected
    Definition Classes
    StdStackClientEndpointerStackClient
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def filtered(filter: Filter[Request, Result, Request, Result]): Client

    Prepends filter to the top of the client.

    Prepends filter to the top of the client. That is, after materializing the client (newClient/newService) filter will be the first element which requests flow through. This is a familiar chaining combinator for filters and is particularly useful for StdStackClient implementations that don't expose services but instead wrap the resulting service with a rich API.

    Definition Classes
    ClientEndpointerStackClient
  13. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def newClient(dest: Name, label0: String): ServiceFactory[Request, Result]

    Create a new client connected to dest.

    Create a new client connected to dest. See the user guide for details on destination names.

    Argument label is used to assign a label to this client. The label is used to display stats, etc.

    label0

    if an empty String is provided, then the label from the Label Stack.Params is used. If that is also an empty String, then dest is used.

    Definition Classes
    EndpointerStackClientClient
  18. final def newClient(dest: String, label: String): ServiceFactory[Request, Result]

    Create a new client connected to dest.

    Create a new client connected to dest. See the user guide for details on destination names.

    Argument label is used to assign a label to this client. The label is used to display stats, etc.

    Definition Classes
    Client
  19. final def newClient(dest: String): ServiceFactory[Request, Result]

    Create a new client connected to dest.

    Create a new client connected to dest. See the user guide for details on destination names.

    Definition Classes
    Client
  20. def newDispatcher(transport: Transport[Buf, Buf] { type Context <: Client.this.Context }): Service[Request, Result]

    Defines a dispatcher, a function which reconciles the stream based Transport with a Request/Response oriented Service.

    Defines a dispatcher, a function which reconciles the stream based Transport with a Request/Response oriented Service. Together with a Transporter, it forms the foundation of a finagle client. Concrete implementations are expected to specify this.

    Attributes
    protected
    Definition Classes
    ClientStdStackClient
    See also

    com.twitter.finagle.dispatch.GenSerialServerDispatcher

  21. def newRichClient(dest: String): mysql.Client with Transactions

    Creates a new RichClient connected to the logical destination described by dest.

    Creates a new RichClient connected to the logical destination described by dest.

    Definition Classes
    MysqlRichClient
  22. def newRichClient(dest: Name, label: String): mysql.Client with Transactions

    Creates a new RichClient connected to the logical destination described by dest with the assigned label.

    Creates a new RichClient connected to the logical destination described by dest with the assigned label. The label is used to scope client stats.

    Definition Classes
    MysqlRichClient
  23. def newService(dest: Name, label: String): Service[Request, Result]

    Create a new service which dispatches requests to dest.

    Create a new service which dispatches requests to dest. See the user guide for details on destination names.

    Argument label is used to assign a label to this client. The label is used to display stats, etc.

    Definition Classes
    EndpointerStackClientClient
  24. final def newService(dest: String, label: String): Service[Request, Result]

    Create a new service which dispatches requests to dest.

    Create a new service which dispatches requests to dest. See the user guide for details on destination names.

    Definition Classes
    Client
  25. final def newService(dest: String): Service[Request, Result]

    Create a new service which dispatches requests to dest.

    Create a new service which dispatches requests to dest. See the user guide for details on destination names.

    Definition Classes
    Client
  26. def newTransporter(addr: SocketAddress): Transporter[In, Out, Context]

    Defines a typed com.twitter.finagle.client.Transporter for this client.

    Defines a typed com.twitter.finagle.client.Transporter for this client. Concrete StackClient implementations are expected to specify this.

    Attributes
    protected
    Definition Classes
    ClientStdStackClient
  27. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  28. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  29. val params: Params
    Definition Classes
    ClientStackClientParameterized
  30. final def registerTransporter(transporterName: String): Unit

    Export info about the transporter type so that we can query info about its implementation at runtime.

    Export info about the transporter type so that we can query info about its implementation at runtime.

    Attributes
    protected
    Definition Classes
    StackClient
  31. def richClientStatsReceiver: StatsReceiver
    Definition Classes
    ClientMysqlRichClient
  32. val stack: Stack[ServiceFactory[Request, Result]]
    Definition Classes
    ClientStackClient
  33. val supportUnsigned: Boolean
    Attributes
    protected
    Definition Classes
    ClientMysqlRichClient
  34. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  35. def transformed(f: (Stack[ServiceFactory[Request, Result]]) ⇒ Stack[ServiceFactory[Request, Result]]): Client

    Creates a new StackClient with f applied to stack.

    Creates a new StackClient with f applied to stack.

    For expert users only.

    Definition Classes
    EndpointerStackClient
  36. def transformed(t: Transformer): StackClient[Request, Result]

    Transform the stack using the given Transformer.

    Transform the stack using the given Transformer.

    Definition Classes
    StackClientTransformable
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  40. val withAdmissionControl: ClientAdmissionControlParams[Client]
    Definition Classes
    ClientWithClientAdmissionControl
  41. def withAffectedRows(): Client

    Don't set the CLIENT_FOUND_ROWS flag when establishing a new session.

    Don't set the CLIENT_FOUND_ROWS flag when establishing a new session. This will make "INSERT ... ON DUPLICATE KEY UPDATE" statements return the "correct" update count.

    See https://dev.mysql.com/doc/refman/5.7/en/information-functions.html#function_row-count

  42. def withCharset(charset: Short): Client

    The default character set used when establishing a new session.

  43. def withCredentials(u: String, p: String): Client

    The credentials to use when authenticating a new session.

  44. def withDatabase(db: String): Client

    Database to use when this client establishes a new session.

  45. def withExceptionStatsHandler(exceptionStatsHandler: ExceptionStatsHandler): Client

    Configures this server or client with given exception stats handler.

    Configures this server or client with given exception stats handler.

    Definition Classes
    ClientCommonParams
  46. def withLabel(label: String): Client

    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
    ClientCommonParams
  47. val withLoadBalancer: DefaultLoadBalancingParams[Client]
    Definition Classes
    ClientWithDefaultLoadBalancer
  48. def withMaxConcurrentPrepareStatements(num: Int): Client

    The maximum number of concurrent prepare statements.

  49. def withMonitor(monitor: Monitor): Client

    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
    ClientCommonParams
  50. def withParams(params: Params): Client

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

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

    Definition Classes
    EndpointerStackClientStackClientParameterized
  51. def withRequestTimeout(timeout: Duration): Client

    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
    ClientCommonParams
    See also

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

  52. def withRequestTimeout(timeout: Tunable[Duration]): Client

    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): Client

    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
    ClientCommonParams
    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. def withRetryBackoff(backoff: Stream[Duration]): Client

    Configures the requeue backoff policy of this client (default: no delay).

    Configures the requeue backoff policy of this client (default: no delay).

    The backoff policy is represented by a stream of delays (i.e., Stream[Duration]) used to delay each retry.

    Definition Classes
    ClientClientParams
    See also

    https://twitter.github.io/finagle/guide/Clients.html#retries

  55. def withRetryBudget(budget: RetryBudget): Client

    Configures the retry budget of this client (default: allows for about 20% of the total requests to be retried on top of 10 retries per second).

    Configures the retry budget of this client (default: allows for about 20% of the total requests to be retried on top of 10 retries per second).

    This budget is shared across requests and governs the number of retries that can be made by this client.

    Definition Classes
    ClientClientParams
    Note

    The retry budget helps prevent clients from overwhelming the downstream service.

    See also

    https://twitter.github.io/finagle/guide/Clients.html#retries

  56. val withSession: ClientSessionParams[Client]
    Definition Classes
    ClientWithClientSession
  57. val withSessionPool: SessionPoolingParams[Client]
    Definition Classes
    ClientWithSessionPool
  58. val withSessionQualifier: SessionQualificationParams[Client]
    Definition Classes
    ClientWithSessionQualifier
  59. def withStack(stack: Stack[ServiceFactory[Request, Result]]): Client

    A new StackClient with the provided stack.

    A new StackClient with the provided stack.

    Definition Classes
    ClientEndpointerStackClientStackClient
  60. def withStatsReceiver(statsReceiver: StatsReceiver): Client

    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
    ClientCommonParams
  61. def withTracer(tracer: Tracer): Client

    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
    ClientCommonParams
  62. val withTransport: ClientTransportParams[Client]
    Definition Classes
    ClientWithClientTransport

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from MysqlRichClient

Inherited from WithSessionPool[Client]

Inherited from StdStackClient[Request, Result, Client]

Inherited from WithSessionQualifier[Client]

Inherited from WithClientSession[Client]

Inherited from WithClientTransport[Client]

Inherited from ClientParams[Client]

Inherited from CommonParams[Client]

Inherited from StackClient[Request, Result]

Inherited from StackBasedClient[Request, Result]

Inherited from Parameterized[Client]

Inherited from finagle.Client[Request, Result]

Inherited from AnyRef

Inherited from Any

Ungrouped