com.twitter.inject.thrift.modules
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
This method allows for further configuration of the client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,
This method allows for further configuration of the client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,
override def configureNonThriftMuxClient(client: Thrift.Client): Thrift.Client = { client .withProtocolFactory(myCustomProtocolFactory)) .withStatsReceiver(someOtherScopedStatsReceiver) .withMonitor(myAwesomeMonitor) .withTracer(notTheDefaultTracer) .withResponseClassifier(ThriftResponseClassifier.ThriftExceptionsAsFailures) }
In general it is recommended that users prefer to use ThriftMux if the server-side supports mux connections.
- the com.twitter.finagle.Thrift.Client to configure.
a configured Thrift.Client.
This method allows for further configuration of the client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,
This method allows for further configuration of the client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,
override def configureThriftMuxClient(client: ThriftMux.Client): ThriftMux.Client = { client .withProtocolFactory(myCustomProtocolFactory)) .withStatsReceiver(someOtherScopedStatsReceiver) .withMonitor(myAwesomeMonitor) .withTracer(notTheDefaultTracer) .withResponseClassifier(ThriftResponseClassifier.ThriftExceptionsAsFailures) }
- the com.twitter.finagle.ThriftMux.Client to configure.
a configured ThriftMux.Client.
Add filters to the ServiceIface.
Add filters to the ServiceIface. This is done by copying the ServiceIface then filtering each method as desired via a com.twitter.inject.thrift.filters.ThriftClientFilterChain returned from com.twitter.inject.thrift.filters.ThriftClientFilterBuilder.method. E.g.,
filters.method(FetchBlob) .withMethodLatency .withConstantRetry( shouldRetryResponse = PossiblyRetryableExceptions, start = 50.millis, retries = 3) .withRequestLatency .withRequestTimeout(250.millis) .withConcurrencyLimit( initialPermits = 500) .filtered(new MyFilter) .filtered[MyOtherFilter] .andThen(serviceIface.fetchBlob))
Note: the com.twitter.inject.thrift.filters.ThriftClientFilterChain supports adding filters either by instance or by type.
Subclasses of this module MAY provide an implementation of filterServiceIface
which filters the ServiceIface
per-method.
- the ServiceIface to filter per-method.
- a com.twitter.inject.thrift.filters.ThriftClientFilterBuilder which can be invoked to construct a com.twitter.inject.thrift.filters.ThriftClientFilterChain per-method.
a per-method filtered ServiceIface
Function to add a user-defined Monitor, c.t.finagle.DefaultMonitor will be installed implicitly which handles all exceptions caught in stack.
Function to add a user-defined Monitor, c.t.finagle.DefaultMonitor will be installed implicitly which handles all exceptions caught in stack. Exceptions aren't handled by user-defined monitor propagated to the default monitor.
NullMonitor has no influence on DefaultMonitor behavior here
Enable thrift mux for this connection.
Enable thrift mux for this connection.
Note: Both server and client must have mux enabled otherwise a nondescript ChannelClosedException will be seen.
Configures the session acquisition timeout
of this client (default: unbounded).
Configures the session acquisition timeout
of this client (default: unbounded).
an org.joda.time.Duration which represents the acquisition timeout
Use a high resolution com.twitter.util.Timer such that retries are run tighter to their schedule.
Use a high resolution com.twitter.util.Timer such that retries are run tighter to their schedule. Default: false.
Note: There are performance implications to enabling.
Provides a FutureIface in the form of
RemoteService[Future]
for making calls to a remote service. The FutureIface (e.g., RemoteService[Future]) wraps a ServiceIface in which each method is implemented in the form of a com.twitter.finagle.Service typed from com.twitter.scrooge.ThriftMethod.Args to com.twitter.scrooge.ThriftMethod.SuccessType.A FutureIface of
RemoteService[Future]
is used as this is the FutureIface type generated by Scrooge's "services-per-endpoint" functionality e.g. the result of callingThrift.client.newMethodIface(...)
; as opposed to the functionally equivalentRemoteService.FutureIface
.To provide per-method filters to the ServiceIface provide an implementation of filterServiceIface and use the provided com.twitter.inject.thrift.filters.ThriftClientFilterBuilder to filter methods. E.g.,
serviceIface.copy( fetchBlob = filters.method(FetchBlob) .withMethodLatency .withExponentialRetry( shouldRetryResponse = PossiblyRetryableExceptions, start = 50.millis, multiplier = 2, retries = 3) .withRequestLatency .withRequestTimeout(500.millis) .withConcurrencyLimit( initialPermits = 100) .filtered(new MyFilter) .filtered[MyOtherFilter] .andThen(serviceIface.fetchBlob))
Finagle Clients
Services-per-endpoint in Scrooge
com.twitter.finagle.thrift.MethodIfaceBuilder