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 ThriftMux extends Client[ThriftClientRequest, Array[Byte]] with Server[Array[Byte], Array[Byte]]

    The ThriftMux object is both a com.twitter.finagle.Client and a com.twitter.finagle.Server for the Thrift protocol served over com.twitter.finagle.mux.

    The ThriftMux object is both a com.twitter.finagle.Client and a com.twitter.finagle.Server for the Thrift protocol served over com.twitter.finagle.mux. Rich interfaces are provided to adhere to those generated from a Thrift IDL by Scrooge or thrift-finagle.

    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 ThriftMux.Client.build:

    ThriftMux.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:

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

    In Java, we need to provide the class object:

    TestService.MethodPerEndpoint client =
      ThriftMux.client.build(addr, TestService.MethodPerEndpoint.class);

    Servers

    Servers are also simple to expose:

    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)
    })

    This object does not expose any configuration options. Both clients and servers are instantiated with sane defaults. Clients are labeled with the "clnt/thrift" prefix and servers with "srv/thrift". If you'd like more configuration, see the configuration documentation.

    Definition Classes
    finagle
  • Client
  • Server

case class Client(muxer: StackClient[Request, Response] = Client.standardMuxer) extends StackBasedClient[ThriftClientRequest, Array[Byte]] with Parameterized[Client] with Transformable[Client] with CommonParams[Client] with ClientParams[Client] with WithClientTransport[Client] with WithClientAdmissionControl[Client] with WithClientSession[Client] with WithSessionQualifier[Client] with WithDefaultLoadBalancer[Client] with WithThriftPartitioningStrategy[Client] with ThriftRichClient with OpportunisticTlsParams[Client] with WithCompressionPreferences[Client] with Product with Serializable

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

Instance Constructors

  1. new Client(muxer: StackClient[Request, Response] = Client.standardMuxer)

Type Members

  1. class MultiplexedThriftClient extends AnyRef
    Definition Classes
    ThriftRichClient

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 build[ThriftServiceType](name: Name, label: String, cls: Class[_], clientParam: RichClientParam, service: Service[ThriftClientRequest, Array[Byte]]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  6. def build[ThriftServiceType](name: Name, label: String, cls: Class[_]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  7. def build[ThriftServiceType](dest: Name, label: String)(implicit arg0: ClassTag[ThriftServiceType]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  8. def build[ThriftServiceType](dest: String, label: String)(implicit arg0: ClassTag[ThriftServiceType]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  9. def build[ThriftServiceType](dest: String)(implicit arg0: ClassTag[ThriftServiceType]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  10. def build[ThriftServiceType](dest: String, label: String, cls: Class[_]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  11. def build[ThriftServiceType](dest: String, cls: Class[_]): ThriftServiceType

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    Create a new client of type ThriftServiceType, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
  12. val clientParam: RichClientParam
    Attributes
    protected
    Definition Classes
    ClientThriftRichClient
  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  14. def configured[P](psp: (P, Param[P])): Client

    Java friendly API for configured.

    Java friendly API for configured.

    The Tuple2 can often be created by calls to a mk(): (P, Stack.Param[P]) method on parameters (see com.twitter.finagle.loadbalancer.LoadBalancerFactory.Param.mk() as an example).

    Definition Classes
    ClientParameterized
  15. def configured[P](p: P)(implicit sp: Param[P]): Client

    Add the parameter, p, to the current Params.

    Add the parameter, p, to the current Params.

    Java users may find it easier to use the Tuple2 version below.

    Definition Classes
    Parameterized
  16. def configuredParams(newParams: Params): Client

    Adds all parameters, newParams, to the current Params.

    Adds all parameters, newParams, to the current Params.

    Definition Classes
    Parameterized
  17. lazy val defaultClientName: String

    The client name used when group isn't named.

    The client name used when group isn't named.

    Attributes
    protected
    Definition Classes
    ClientThriftRichClient
  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def filtered(filter: Filter[Request, Response, Request, Response]): 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.

  20. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  21. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  22. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  23. def methodBuilder(dest: Name): MethodBuilder

    Create a thriftmux.MethodBuilder for a given destination.

    Create a thriftmux.MethodBuilder for a given destination.

    See also

    user guide

  24. def methodBuilder(dest: String): MethodBuilder

    Create a thriftmux.MethodBuilder for a given destination.

    Create a thriftmux.MethodBuilder for a given destination.

    See also

    user guide

  25. def multiplex[T](dest: String, label: String)(build: (MultiplexedThriftClient) => T): T

    Build client interfaces for multiplexed thrift services.

    Build client interfaces for multiplexed thrift services.

    E.g.

    val client = Thrift.client.multiplex(address, "client") { client =>
      new {
        val echo = client.newIface[Echo.MethodPerEndpoint]("echo")
        val extendedEcho = client.newServiceIface[ExtendedEcho.ServiceIface]("extendedEcho")
      }
    }
    
    client.echo.echo("hello")
    client.extendedEcho.getStatus(ExtendedEcho.GetStatus.Args())
    Definition Classes
    ThriftRichClient
  26. def multiplex[T](dest: Name, label: String)(build: (MultiplexedThriftClient) => T): T

    Build client interfaces for multiplexed thrift services.

    Build client interfaces for multiplexed thrift services.

    E.g.

    val client = Thrift.client.multiplex(address, "client") { client =>
      new {
        val echo = client.newIface[Echo.MethodPerEndpoint]("echo")
        val extendedEcho = client.newServiceIface[ExtendedEcho.ServiceIface]("extendedEcho")
      }
    }
    
    client.echo.echo("hello")
    client.extendedEcho.getStatus(ExtendedEcho.GetStatus.Args())
    Definition Classes
    ThriftRichClient
  27. val muxer: StackClient[Request, Response]
  28. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. def newClient(dest: Name, label: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

    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
    ClientClient
  30. final def newClient(dest: String, label: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

    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
  31. final def newClient(dest: String): ServiceFactory[ThriftClientRequest, Array[Byte]]

    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
  32. def newService(dest: Name, label: String): Service[ThriftClientRequest, Array[Byte]]

    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
    ClientClient
  33. final def newService(dest: String, label: String): Service[ThriftClientRequest, Array[Byte]]

    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
  34. final def newService(dest: String): Service[ThriftClientRequest, Array[Byte]]

    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
  35. def newServicePerEndpoint[ServicePerEndpoint <: Filterable[ServicePerEndpoint]](service: Service[ThriftClientRequest, Array[Byte]], label: String)(implicit builder: ServicePerEndpointBuilder[ServicePerEndpoint]): ServicePerEndpoint

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method:

    val loggerService: Logger.ServicePerEndpoint = Thrift.client.servicePerEndpoint[Logger.ServicePerEndpoint]("localhost:8000", "client_label")
    val response: String = loggerService.log(Logger.Log.Args("log message", 1))

    You can also create a Finagle Service[scrooge.Request, scrooge.Response] per-endpoint (method) for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method that uses the Scrooge Request/Response envelopes:

    val loggerService: Logger.ReqRepServicePerEndpoint = Thrift.client.servicePerEndpoint[Logger.ReqRepServicePerEndpoint]("localhost:8000", "client_label")
    val response: c.t.scrooge.Response[String] = loggerService.log(c.t.scrooge.Request(Logger.Log.Args("log message", 1)))

    This allows you to access any contained c.t.scrooge.Request and c.t.scrooge.Response headers.

    service

    The Finagle Service to be used.

    label

    Assign a label for scoped stats.

    builder

    The builder type is generated by Scrooge for a thrift service.

    Attributes
    protected
    Definition Classes
    ThriftRichClient
  36. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  37. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  38. def params: Params
    Definition Classes
    ClientParameterized
  39. def productElementNames: Iterator[String]
    Definition Classes
    Product
  40. def servicePerEndpoint[ServicePerEndpoint <: Filterable[ServicePerEndpoint]](dest: Name, label: String)(implicit builder: ServicePerEndpointBuilder[ServicePerEndpoint]): ServicePerEndpoint

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method:

    val loggerService: Logger.ServicePerEndpoint = Thrift.client.servicePerEndpoint[Logger.ServicePerEndpoint]("localhost:8000", "client_label")
    val response: String = loggerService.log(Logger.Log.Args("log message", 1))

    You can also create a Finagle Service[scrooge.Request, scrooge.Response] per-endpoint (method) for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method that uses the Scrooge Request/Response envelopes:

    val loggerService: Logger.ReqRepServicePerEndpoint = Thrift.client.servicePerEndpoint[Logger.ReqRepServicePerEndpoint]("localhost:8000", "client_label")
    val response: c.t.scrooge.Response[String] = loggerService.log(c.t.scrooge.Request(Logger.Log.Args("log message", 1)))

    This allows you to access any contained c.t.scrooge.Request and c.t.scrooge.Response headers.

    dest

    Address of the service to connect to.

    label

    Assign a label for scoped stats.

    builder

    The builder type is generated by Scrooge for a thrift service.

    Definition Classes
    ThriftRichClient
  41. def servicePerEndpoint[ServicePerEndpoint <: Filterable[ServicePerEndpoint]](dest: String, label: String)(implicit builder: ServicePerEndpointBuilder[ServicePerEndpoint]): ServicePerEndpoint

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method:

    val loggerService: Logger.ServicePerEndpoint = Thrift.client.servicePerEndpoint[Logger.ServicePerEndpoint]("localhost:8000", "client_label")
    val response: String = loggerService.log(Logger.Log.Args("log message", 1))

    You can also create a Finagle Service[scrooge.Request, scrooge.Response] per-endpoint (method) for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method that uses the Scrooge Request/Response envelopes:

    val loggerService: Logger.ReqRepServicePerEndpoint = Thrift.client.servicePerEndpoint[Logger.ReqRepServicePerEndpoint]("localhost:8000", "client_label")
    val response: c.t.scrooge.Response[String] = loggerService.log(c.t.scrooge.Request(Logger.Log.Args("log message", 1)))

    This allows you to access any contained c.t.scrooge.Request and c.t.scrooge.Response headers.

    dest

    Address of the service to connect to, in the format accepted by Resolver.eval.

    label

    Assign a label for scoped stats.

    builder

    The builder type is generated by Scrooge for a thrift service.

    Definition Classes
    ThriftRichClient
  42. def stack: Stack[ServiceFactory[Request, Response]]
  43. def stats: StatsReceiver
    Attributes
    protected
    Definition Classes
    ThriftRichClient
  44. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  45. def transformed(t: Transformer): Client

    Transform the stack using the given Transformer.

    Transform the stack using the given Transformer.

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

    An entry point for configuring the clients' admission control

    An entry point for configuring the clients' admission control

    Definition Classes
    ClientWithClientAdmissionControl
  50. def withClientId(clientId: ClientId): Client

    Produce a com.twitter.finagle.ThriftMux.Client using the provided client ID.

  51. val withCompressionPreferences: CompressionParams[Client]

    An entry point for configuring the client or server's compression.

    An entry point for configuring the client or server's compression.

    Definition Classes
    WithCompressionPreferences
  52. 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
  53. def withExecutionOffloaded(pool: FuturePool): Client

    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
    ClientCommonParams
  54. def withExecutionOffloaded(executor: ExecutorService): Client

    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
    ClientCommonParams
  55. 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
  56. def withLabels(keywords: String*): Client
    Definition Classes
    CommonParams
  57. val withLoadBalancer: DefaultLoadBalancingParams[Client]

    An entry point for configuring the client's load balancer that implements a strategy for choosing one host/node from a replica set to service a request.

    An entry point for configuring the client's load balancer that implements a strategy for choosing one host/node from a replica set to service a request.

    The default setup for a Finagle client is to use power of two choices algorithm to distribute load across endpoints, and comparing nodes via a least loaded metric.

    Definition Classes
    ClientWithDefaultLoadBalancer
    See also

    https://twitter.github.io/finagle/guide/Clients.html#load-balancing

  58. def withMaxReusableBufferSize(size: Int): Client

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

    Produce a com.twitter.finagle.ThriftMux.Client 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.

    Note

    MaxReusableBufferSize will be ignored if TReusableBufferFactory is set.

  59. def withMonitor(monitor: Monitor): Client

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

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

    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 configured Monitor is composed (see below for how composition works) with the default monitor implementation, com.twitter.finagle.util.DefaultMonitor, which 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
    ClientCommonParams
  60. def withNoOpportunisticTls: Client

    Disables opportunistic TLS.

    Disables opportunistic TLS.

    If this is still TLS configured, it will speak mux over TLS. To instead configure this to be Off, use withOpportunisticTls(OpportunisticTls.Off).

    Definition Classes
    ClientOpportunisticTlsParams
  61. def withOpportunisticTls(level: Level): Client

    Configures whether to speak TLS or not.

    Configures whether to speak TLS or not.

    By default, don't use opportunistic TLS, and instead try to speak mux over TLS if TLS has been configured.

    The valid levels are Off, which indicates this will never speak TLS, Desired, which indicates it may speak TLS, but may also not speak TLS, and Required, which indicates it must speak TLS.

    Peers that are configured with level Required cannot speak to peers that are configured with level Off.

    Note that opportunistic TLS is negotiated in a cleartext handshake, and is incompatible with mux over TLS.

    Definition Classes
    ClientOpportunisticTlsParams
  62. def withParams(ps: Params): Client
    Definition Classes
    ClientParameterized
  63. val withPartitioning: PartitioningParams[Client]

    An entry point for configuring Thrift/ThriftMux client's partitioning service

    An entry point for configuring Thrift/ThriftMux client's partitioning service

    Definition Classes
    ClientWithThriftPartitioningStrategy
  64. def withPerEndpointStats: Client

    Produce a com.twitter.finagle.ThriftMux.Client with per-endpoint stats filters

  65. def withProtocolFactory(pf: TProtocolFactory): Client

    Produce a com.twitter.finagle.ThriftMux.Client using the provided protocolFactory.

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

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

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

  69. def withRetryBackoff(backoff: Backoff): Client

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

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

    The policy encoded Backoff is used to calculate the next duration to delay each retry.

    Definition Classes
    ClientClientParams
    See also

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

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

  71. def withServiceClass(clazz: Class[_]): Client

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

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

    Note

    that when using the .build methods this is unnecessary.

  72. val withSession: ClientSessionParams[Client]

    An entry point for configuring the client's session.

    An entry point for configuring the client's session.

    Definition Classes
    ClientWithClientSession
  73. val withSessionQualifier: SessionQualificationParams[Client]

    An entry point for configuring the client's session qualifiers (e.g.

    An entry point for configuring the client's session qualifiers (e.g. circuit breakers).

    Definition Classes
    ClientWithSessionQualifier
    See also

    https://twitter.github.io/finagle/guide/Clients.html#circuit-breaking

  74. def withStack(fn: (Stack[ServiceFactory[Request, Response]]) => Stack[ServiceFactory[Request, Response]]): Client
  75. def withStack(stack: Stack[ServiceFactory[Request, Response]]): Client

    Produce a com.twitter.finagle.ThriftMux.Client using the provided stack.

  76. 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
  77. def withTReusableBufferFactory(tReusableBufferFactory: () => TReusableBuffer): Client

    Produce a com.twitter.finagle.ThriftMux.Client with a factory creates new TReusableBuffer, the TReusableBuffer can be shared with other client instance.

    Produce a com.twitter.finagle.ThriftMux.Client with a factory creates new TReusableBuffer, the TReusableBuffer can be shared with other client instance. If set, the MaxReusableBufferSize will be ignored.

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

  79. val withTransport: ClientTransportParams[Client]

    An entry point for configuring the client's com.twitter.finagle.transport.Transport.

    An entry point for configuring the client's com.twitter.finagle.transport.Transport.

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

    Definition Classes
    ClientWithClientTransport

Deprecated Value Members

  1. def newIface[Iface](name: Name, label: String, cls: Class[_], protocolFactory: TProtocolFactory, service: Service[ThriftClientRequest, Array[Byte]]): Iface
    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-8-16) Use com.twitter.finagle.thrift.RichClientParam

  2. def newIface[Iface](name: Name, label: String, cls: Class[_], clientParam: RichClientParam, service: Service[ThriftClientRequest, Array[Byte]]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  3. def newIface[Iface](name: Name, label: String, cls: Class[_]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  4. def newIface[Iface](dest: Name, label: String)(implicit arg0: ClassTag[Iface]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  5. def newIface[Iface](dest: String, label: String)(implicit arg0: ClassTag[Iface]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  6. def newIface[Iface](dest: String)(implicit arg0: ClassTag[Iface]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  7. def newIface[Iface](dest: String, label: String, cls: Class[_]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  8. def newIface[Iface](dest: String, cls: Class[_]): Iface

    Create a new client of type Iface, which must be generated by Scrooge.

    Create a new client of type Iface, which must be generated by Scrooge.

    For Scala generated code, the Class passed in should be either ServiceName$MethodPerEndpoint or ServiceName[Future].

    For Java generated code, the Class passed in should be ServiceName$ServiceIface.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-20) Use com.twitter.finagle.ThriftRichClient#build

  9. def newServiceIface[ServiceIface <: Filterable[ServiceIface]](dest: Name, label: String)(implicit builder: ServiceIfaceBuilder[ServiceIface]): ServiceIface

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method:

    val loggerService: Logger.ServiceIface = Thrift.client.newServiceIface[Logger.ServiceIface]("localhost:8000", "client_label")
    val response: String = loggerService.log(Logger.Log.Args("log message", 1))
    dest

    Address of the service to connect to.

    label

    Assign a label for scoped stats.

    builder

    The builder type is generated by Scrooge for a thrift service.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-13) Use com.twitter.finagle.ThriftRichClient#servicePerEndpoint[ServicePerEndpoint]

  10. def newServiceIface[ServiceIface <: Filterable[ServiceIface]](dest: String, label: String)(implicit builder: ServiceIfaceBuilder[ServiceIface]): ServiceIface

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    Construct a Finagle Service interface for a Scrooge-generated Thrift object.

    E.g. given a Thrift service

    service Logger {
      string log(1: string message, 2: i32 logLevel);
      i32 getLogSize();
    }

    you can construct a client interface with a Finagle Service per Thrift method:

    val loggerService: Logger.ServiceIface = Thrift.client.newServiceIface[Logger.ServiceIface]("localhost:8000", "client_label")
    val response: String = loggerService.log(Logger.Log.Args("log message", 1))
    dest

    Address of the service to connect to, in the format accepted by Resolver.eval.

    label

    Assign a label for scoped stats.

    builder

    The builder type is generated by Scrooge for a thrift service.

    Definition Classes
    ThriftRichClient
    Annotations
    @deprecated
    Deprecated

    (Since version 2017-11-13) Use com.twitter.finagle.ThriftRichClient#servicePerEndpoint[ServicePerEndpoint]

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from ThriftRichClient

Inherited from WithClientSession[Client]

Inherited from WithClientTransport[Client]

Inherited from ClientParams[Client]

Inherited from CommonParams[Client]

Inherited from Transformable[Client]

Inherited from Parameterized[Client]

Inherited from AnyRef

Inherited from Any

Ungrouped