class ThriftClientFilterChain[Req <: ThriftStruct, Rep] extends Logging
A com.twitter.finagle.Filter chain builder which provides helper functions for installing and configuring common filters.
Filters configured via the helper methods, e.g., withRetryPolicy, withTimeout, withRequestTimeout, withMethodLatency, withExceptionFilter, will be composed in a specific order, (from top-down, assuming requests/responses enter and exit through the top):
+------------------------+
latencyFilter |
|---|
+------------------------+
exceptionFilter |
|---|
+------------------------+
timeoutFilter |
|---|
+------------------------+
retryFilter |
|---|
+------------------------+
requestTimeoutFilter |
|---|
+------------------------+
concurrencyLimitFilter |
|---|
+------------------------+
filterChain |
|---|
+------------------------+
where, the filterChain is the chain of filters added in the order of calls to filtered.
- Req
Request type for this filter chain
- Rep
Response type for this filter chain
- Annotations
- @deprecated
- Deprecated
(Since version 2018-01-12) Use ThriftMethodBuilderClientModule and ThriftMethodBuilder
- See also
com.twitter.finagle.thrift.service.ThriftServicePerEndpoint
- Alphabetic
- By Inheritance
- ThriftClientFilterChain
- Logging
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ThriftClientFilterChain(injector: Injector, statsReceiver: StatsReceiver, clientLabel: String, budget: Budget, method: ThriftMethod, timeoutMultiplier: Int, retryMultiplier: Int, useHighResTimerForRetries: Boolean, andThenService: AndThenService)
- injector
- statsReceiver
a com.twitter.finagle.stats.StatsReceiver
- clientLabel
the thrift client label
- budget
the configured com.twitter.finagle.service.RetryBudget
- method
the com.twitter.scrooge.ThriftMethod for which this filter chain is configured
- timeoutMultiplier
a multiplier to apply to timeouts used in any configures com.twitter.finagle.service.TimeoutFilter
- retryMultiplier
a multiplier to apply to the number of retries used in any configured com.twitter.finagle.service.RetryFilter
- useHighResTimerForRetries
if a high resolution com.twitter.util.Timer should be used such that retries are run tighter to their schedule
- andThenService
the com.twitter.finagle.Service to invoke after the filter chain
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
andThen(service: Service[Req, Rep]): Service[Req, Rep]
After this filter chain is executed this is the com.twitter.finagle.Service to invoke.
After this filter chain is executed this is the com.twitter.finagle.Service to invoke. The layer of indirection is to allow for servers that wish to intercept the invocation of the bottom service.
- service
the com.twitter.finagle.Service to invoke at the end of this filter chain
- returns
a com.twitter.finagle.Service with this filter chain applied
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
var
concurrencyLimitFilter: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
def
debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debugFutureResult[T](msg: String)(func: ⇒ Future[T]): Future[T]
- Attributes
- protected
- Definition Classes
- Logging
-
def
debugResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
defaultRetryMsg(requestAndResponse: (Req, Try[Rep]), duration: Duration): String
- Attributes
- protected
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
errorResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
var
exceptionFilterImpl: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
var
filterChain: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
def
filtered[T <: Filter[Req, Rep, Req, Rep]](implicit arg0: Manifest[T]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.Filter.
Install a com.twitter.finagle.Filter. This filter will be added to the end of the filter chain. That is, this filter will be invoked AFTER any other installed filter on a request Req and thus BEFORE any other installed filter on a response Rep.
- T
the type of the filter to instantiate from the injector
- returns
-
def
filtered(filter: Filter[Req, Rep, Req, Rep]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.Filter.
Install a com.twitter.finagle.Filter. This filter will be added to the end of the filter chain. That is, this filter will be invoked AFTER any other installed filter on a request Req and thus BEFORE any other installed filter on a response Rep.
- filter
the com.twitter.finagle.Filter to install.
- returns
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
infoResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isDebugEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isDebugEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isErrorEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isErrorEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isInfoEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isInfoEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isTraceEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isTraceEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isWarnEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isWarnEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
logger: Logger
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
loggerName: String
- Attributes
- protected[this]
- Definition Classes
- Logging
-
var
methodLatencyFilter: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
var
requestLatencyFilter: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
var
requestTimeoutFilter: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
var
retryFilter: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
def
scopeStatsReceiver(): StatsReceiver
Example scope: clnt/thrift/Adder/add1String
Example scope: clnt/thrift/Adder/add1String
- Attributes
- protected[com.twitter.inject.thrift]
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
time[T](formatStr: String)(func: ⇒ T): T
- Attributes
- protected
- Definition Classes
- Logging
-
var
timeoutFilter: Filter[Req, Rep, Req, Rep]
- Attributes
- protected
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
traceResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warnResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
withAgnosticFilter[T <: TypeAgnostic](implicit arg0: Manifest[T]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.Filter.TypeAgnostic that is agnostic to the ThriftMethod Req/Rep types.
Install a com.twitter.finagle.Filter.TypeAgnostic that is agnostic to the ThriftMethod Req/Rep types. This allows for use of more general filters that do not care about the ThriftMethod input and output types.
- T
the type of the filter to instantiate from the injector
- returns
-
def
withAgnosticFilter(filter: TypeAgnostic): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.Filter that is agnostic to the ThriftMethod Req/Rep types.
Install a com.twitter.finagle.Filter that is agnostic to the ThriftMethod Req/Rep types. This allows for use of more general filters that do not care about the ThriftMethod input and output types.
- filter
the com.twitter.finagle.Filter.TypeAgnostic to install.
- returns
-
def
withConcurrencyLimit(initialPermits: Int, maxWaiters: Option[Int] = None): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.filter.RequestSemaphoreFilter using an com.twitter.concurrent.AsyncSemaphore with an Optional
maxWaitersas the limit on the number of waiters for permits.Install a com.twitter.finagle.filter.RequestSemaphoreFilter using an com.twitter.concurrent.AsyncSemaphore with an Optional
maxWaitersas the limit on the number of waiters for permits.- initialPermits
must be positive
- maxWaiters
must be non-negative if set
- returns
- See also
com.twitter.finagle.filter.RequestSemaphoreFilter
com.twitter.concurrent.AsyncSemaphore
-
def
withConstantRetry(shouldRetry: PartialFunction[(Req, Try[Rep]), Boolean] = PartialFunction.empty, shouldRetryResponse: PartialFunction[Try[Rep], Boolean] = PartialFunction.empty, start: Duration, retries: Int, retryBudget: RetryBudget = budget.retryBudget): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.RetryFilter configured with a com.twitter.finagle.service.RetryPolicy using constant backoffs.
Install a com.twitter.finagle.service.RetryFilter configured with a com.twitter.finagle.service.RetryPolicy using constant backoffs.
- shouldRetry
a PartialFunction over the both the Req and a Try-wrapped returned Rep. Only one of
#shouldRetryor#shouldRetryResponseshould be configured- shouldRetryResponse
a PartialFunction over only the Try-wrapped returned Rep. Only one of
#shouldRetryor#shouldRetryResponseshould be configured- start
how long to delay before retrying
- retries
number of times to retry
- retryBudget
a com.twitter.finagle.service.RetryBudget. It is highly recommended to share a single instance of com.twitter.finagle.service.RetryBudget between both retry and re-queue filters to prevent retry storms. As such, use caution here when specifying a new retryBudget
- returns
- See also
com.twitter.finagle.service.RetryFilter
com.twitter.finagle.service.RetryPolicy
-
def
withExceptionFilter[T <: Filter[Req, Rep, Req, Rep]](implicit arg0: Manifest[T]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.Filter specific to handling exceptions.
Install a com.twitter.finagle.Filter specific to handling exceptions. This filter will be correctly positioned in the filter chain near the top of the stack. This filter is generally used to mutate or alter the final response Req based on a returned exception. E.g., to translate a transport-level exception from Finagle to an application-level exception.
- T
the type of the filter to instantiate from the injector
- returns
-
def
withExceptionFilter(filter: Filter[Req, Rep, Req, Rep]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.Filter specific to handling exceptions.
Install a com.twitter.finagle.Filter specific to handling exceptions. This filter will be correctly positioned in the filter chain near the top of the stack. This filter is generally used to mutate or alter the final response Req based on a returned exception. E.g., to translate a transport-level exception from Finagle to an application-level exception.
- filter
the com.twitter.finagle.Filter to install.
- returns
-
def
withExponentialRetry(shouldRetry: PartialFunction[(Req, Try[Rep]), Boolean] = PartialFunction.empty, shouldRetryResponse: PartialFunction[Try[Rep], Boolean] = PartialFunction.empty, start: Duration, multiplier: Int, retries: Int): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.RetryFilter configured with a com.twitter.finagle.service.RetryPolicy using backoffs that grow exponentially using com.twitter.finagle.service.Backoff#decorrelatedJittered.
Install a com.twitter.finagle.service.RetryFilter configured with a com.twitter.finagle.service.RetryPolicy using backoffs that grow exponentially using com.twitter.finagle.service.Backoff#decorrelatedJittered. The jittered maximum is the
startduration * themultipliervalue.- shouldRetry
a PartialFunction over the both the Req and a Try-wrapped returned Rep. Only one of
#shouldRetryor#shouldRetryResponseshould be configured- shouldRetryResponse
a PartialFunction over only the Try-wrapped returned Rep. Only one of
#shouldRetryor#shouldRetryResponseshould be configured- start
how long to delay before retrying
- multiplier
used to create a jitter with a random distribution between
startand 3 times the previously selected value, capped atstart*multiplier. See: com.twitter.finagle.service.Backoff#decorrelatedJittered- retries
number of times to retry
- returns
- See also
com.twitter.finagle.service.RetryFilter
com.twitter.finagle.service.RetryPolicy
-
def
withMethodLatency: ThriftClientFilterChain[Req, Rep]
A parameter-less implementation with defaults
-
def
withMethodLatency(statsReceiver: StatsReceiver = scopedStatsReceiver, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.inject.thrift.internal.filters.LatencyFilter that tracks the "logical" (overall) latency distribution of a method invocation.
Install a com.twitter.inject.thrift.internal.filters.LatencyFilter that tracks the "logical" (overall) latency distribution of a method invocation. This will INCLUDE any retries as it is installed at the top of the filter stack.
- statsReceiver
a com.twitter.finagle.stats.StatsReceiver to track StatsFilter measurements. By default this will be the class-level StatsReceiver scoped accordingly.
- timeUnit
this controls what granularity is used for measuring latency. The default is milliseconds, but other values are valid. The choice of this changes the name of the stat attached to the given com.twitter.finagle.stats.StatsReceiver. For the common units, it will be "latency_ms".
- returns
- See also
com.twitter.finagle.service.ResponseClassifier
com.twitter.finagle.service.StatsFilter.DefaultExceptions
-
def
withRequestLatency: ThriftClientFilterChain[Req, Rep]
A parameter-less implementation with defaults
-
def
withRequestLatency(statsReceiver: StatsReceiver = scopedStatsReceiver, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.inject.thrift.internal.filters.LatencyFilter that tracks the per-request latency distribution of a method invocation.
Install a com.twitter.inject.thrift.internal.filters.LatencyFilter that tracks the per-request latency distribution of a method invocation. This will per-retry if the invocation results in retried requests.
- statsReceiver
a com.twitter.finagle.stats.StatsReceiver to track StatsFilter measurements. By default this will be the class-level StatsReceiver scoped accordingly.
- timeUnit
this controls what granularity is used for measuring latency. The default is milliseconds, but other values are valid. The choice of this changes the name of the stat attached to the given com.twitter.finagle.stats.StatsReceiver. For the common units, it will be "request_latency_ms".
- returns
- See also
com.twitter.finagle.service.ResponseClassifier
com.twitter.finagle.service.StatsFilter.DefaultExceptions
-
def
withRequestTimeout(duration: Tunable[Duration]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given tunable timeout.
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given tunable timeout. This filter will always be "below" any configured retry filter and thus does NOT include retries.
- duration
the Tunable[Duration] (org.joda.time.Duration) timeout to apply to requests through the filter.
- returns
- See also
com.twitter.finagle.service.TimeoutFilter
-
def
withRequestTimeout(duration: Duration): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given org.joda.time.Duration timeout.
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given org.joda.time.Duration timeout. This filter will always be "below" any configured retry filter and thus does NOT include retries.
- duration
the org.joda.time.Duration timeout to apply to requests through the filter.
- returns
- See also
com.twitter.finagle.service.TimeoutFilter
-
def
withRetryPolicy(retryPolicy: RetryPolicy[(Req, Try[Rep])], retryMsg: ((Req, Try[Rep]), Duration) ⇒ String = defaultRetryMsg): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.RetryFilter configured with the given com.twitter.finagle.service.RetryPolicy.
Install a com.twitter.finagle.service.RetryFilter configured with the given com.twitter.finagle.service.RetryPolicy.
- retryPolicy
the com.twitter.finagle.service.RetryPolicy to use
- retryMsg
a String message to display before retrying thr request.
- returns
- See also
com.twitter.finagle.service.RetryFilter
com.twitter.finagle.service.RetryPolicy
-
def
withTimeout(duration: Tunable[Duration]): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given tunable timeout.
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given tunable timeout. This filter will be "above" any configured retry filter and thus includes retries.
- duration
the Tunable[Duration] (org.joda.time.Duration) timeout to apply to requests through the filter.
- returns
- See also
com.twitter.finagle.service.TimeoutFilter
-
def
withTimeout(duration: Duration): ThriftClientFilterChain[Req, Rep]
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given org.joda.time.Duration timeout.
Install a com.twitter.finagle.service.TimeoutFilter configuration with the given org.joda.time.Duration timeout. This filter will be "above" and configured retry filter and thus includes retries.
- duration
the org.joda.time.Duration timeout to apply to requests through the filter.
- returns
- See also
com.twitter.finagle.service.TimeoutFilter