Create a base Finagle Stack Client of type ClientType.
Create a base Finagle Stack Client of type ClientType. This method should not try to do any configuration on the created client.
The base ClientType client, without any custom configuration.
override def createBaseClient(): Memcached.Client = Memcached.client
override def createBaseClient(): ThriftMux.Client = ThriftMux.client
override def createBaseClient(): Http.Client = Http.client
Destination of Finagle client.
Destination of Finagle client.
Finagle client label.
Finagle client label.
This method should be overridden by implementors IF the ClientType does not extend Closable.
This method should be overridden by implementors IF the ClientType does not extend Closable. This method should wrap an underlying client as a Closable to ensure that resources are dealt with cleanly upon shutdown.
The client that does not extend Closable
The Closable whose logic cleans up client
's resources
override protected def asClosable(client: ClientType): Closable = Closable.make { deadline => // Use a FuturePool to ensure the task is completed asynchronously // and allow for enforcing the deadline Time. FuturePool .unboundedPool { clientType.closeSession() // clean-up resources }.by(deadline)(DefaultTimer) }
override protected def asClosable(client: ClientType): Closable = clientType.asClosable
This method allows for further configuration of the ClientType client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,
This method allows for further configuration of the ClientType client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,
override protected def configureClient(client: Example.Client): Example.Client = { client .withStatsReceiver(someOtherScopedStatsReceiver) .withMonitor(myAwesomeMonitor) .withTracer(notTheDefaultTracer) }
the com.twitter.inject.Injector which can be used to help configure the given ClientType client.
the ClientType client to configure.
a configured ClientType client.
Default amount of time to block in Duration) on
a Closable to close that is registered in a closeOnExit
block.
Default amount of time to block in Duration) on
a Closable to close that is registered in a closeOnExit
block.
a com.twitter.util.Duration
Duration)
Default amount of time to wait for any Closable being registered in a closeOnExit
block.
Default amount of time to wait for any Closable being registered in a closeOnExit
block.
Note that this timeout is advisory, as it attempts to give the close function some leeway, for
example to drain clients or finish up other tasks.
a com.twitter.util.Duration
Duration)
Initial configuration of the underlying client.
Initial configuration of the underlying client. This is exposed to allow for customization of the base client configuration. All user facing extensions should be done via configureClient.
The base configured ClientType client, without any custom end-user configuration.
override protected final def initialClientConfiguration( injector: Injector, client: ClientType, statsReceiver: StatsReceiver ): ThriftMux.Client = super.initialClientConfiguration(injector, client, statsReceiver) .withClientId(injector.instance[ClientId]
Function to add a user-defined Monitor.
Function to add a user-defined Monitor. A com.twitter.finagle.util.DefaultMonitor will be installed implicitly which handles all exceptions caught in the stack. Exceptions that are not handled by a user-defined monitor are propagated to the com.twitter.finagle.util.DefaultMonitor.
NullMonitor has no influence on DefaultMonitor behavior here.
This method will generate a fully configured ClientType
This method will generate a fully configured ClientType
the com.twitter.inject.Injector which can be used to help configure the given ClientType client.
The StatsReceiver to use with the generated ClientType
A configured ClientType
The ability to override this method is exposed for Java compatibility purposes, where the type information in this trait can be erased from this trait to a more generic ClientType, which can cause Java compilation failures. See https://issues.scala-lang.org/browse/SI-8905. When overriding this method, it should treat this method as final, outside of providing a more specific return type. For example:
override protected final def newClient( injector: Injector, statsReceiver: StatsReceiver ): Http.Client = super.newClient(injector, statsReceiver)
This method will generate a Service[Req, Rep]
from the configured ClientType
generated by calling newClient().
This method will generate a Service[Req, Rep]
from the configured ClientType
generated by calling newClient().
the com.twitter.inject.Injector which can be used to help configure the given ClientType client.
The StatsReceiver to use with the generated Service[Req, Rep]
.
A Service[Req, Rep]
that overlays the ClientType
Configures a "global" request timeout
on the Finagle client (default: unbounded).
Configures a "global" request timeout
on the Finagle client (default: unbounded).
This will set *all* requests to *every* method to have the same total timeout.
a Duration which represents the total request timeout
https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration
com.twitter.finagle.param.CommonParams.withRequestTimeout
Default com.twitter.finagle.service.RetryBudget.
Default com.twitter.finagle.service.RetryBudget. It is highly recommended that budgets be shared between all filters that retry or re-queue requests to prevent retry storms.
a default com.twitter.finagle.service.RetryBudget
https://twitter.github.io/finagle/guide/Clients.html#retries
Provide a customized base scope for the StatsReceiver exposed by this module, e.g., * *
Provide a customized base scope for the StatsReceiver exposed by this module, e.g., * *
override protected def scopeStatsReceiver(injector: Injector, statsReceiver: StatsReceiver): StatsReceiver = statsReceiver.scope("clnt", "custom_scope")
Changing the default scope can have negative impacts on observability of metrics. Use caution when changing this value.
,The default scope is "clnt".
Configures the session acquisition timeout
of this client (default: unbounded).
Configures the session acquisition timeout
of this client (default: unbounded).
a Duration which represents the acquisition timeout
https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration
com.twitter.finagle.param.ClientSessionParams.acquisitionTimeout
A module for configuring a Finagle StackBasedClient. Binding is explicitly not handled by this trait and implementors are responsible for managing their own binding annotations.
The ordering of client configuration may be important. The underlying clients will be configured and created in the following order: baseClient -> initialClientConfiguration -> configureClient -> frameworkConfigureClient
,Extending this module for HTTP and ThriftMux clients should not be necessary, as there are fully supported modules for creating those clients.