final class MethodBuilder[Req, Rep] extends Parameterized[MethodBuilder[Req, Rep]]
- Self Type
- MethodBuilder[Req, Rep]
- See also
methodBuilder
methods on client protocols, such asHttp.Client
orThriftMux.Client
for an entry point.
- Alphabetic
- By Inheritance
- MethodBuilder
- Parameterized
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
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
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def configured[P](psp: (P, Param[P])): MethodBuilder[Req, Rep]
Java friendly API for
configured
.Java friendly API for
configured
.The
Tuple2
can often be created by calls to amk(): (P, Stack.Param[P])
method on parameters (see com.twitter.finagle.loadbalancer.LoadBalancerFactory.Param.mk() as an example).- Definition Classes
- Parameterized
- def configured[P](p: P)(implicit sp: Param[P]): MethodBuilder[Req, Rep]
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
- def configuredParams(newParams: Params): MethodBuilder[Req, Rep]
Adds all parameters,
newParams
, to the current Params.Adds all parameters,
newParams
, to the current Params.- Definition Classes
- Parameterized
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def idempotent(maxExtraLoad: Tunable[Double], sendInterrupts: Boolean, classifier: ResponseClassifier): MethodBuilder[Req, Rep]
Configure that requests are to be treated as idempotent.
Configure that requests are to be treated as idempotent. Because requests can be safely retried, BackupRequestFilter is configured with the params maxExtraLoad and sendInterrupts to decrease tail latency by sending an additional fraction of requests.
- maxExtraLoad
How much extra load, as a fraction, we are willing to send to the server. Must be between 0.0 and 1.0.
- sendInterrupts
Whether or not to interrupt the original or backup request when a response is returned and the result of the outstanding request is superseded. For protocols without a control plane, where the connection is cut on interrupts, this should be "false" to avoid connection churn.
- classifier
ResponseClassifier (combined (via ResponseClassifier.orElse) with any existing classifier in the stack params), used for determining whether or not requests have succeeded and should be retried. These determinations are also reflected in stats, and used by FailureAccrualFactory.
- Note
See
idempotent
above for note about low QPS clients and maxExtraLoad
- def idempotent(maxExtraLoad: Tunable[Double], sendInterrupts: Boolean, minSendBackupAfterMs: Int, classifier: ResponseClassifier): MethodBuilder[Req, Rep]
Configure that requests are to be treated as idempotent.
Configure that requests are to be treated as idempotent. Because requests can be safely retried, BackupRequestFilter is configured with the params
maxExtraLoad
andsendInterrupts
to decrease tail latency by sending an additional fraction of requests.If you are using TwitterServer, a good starting point for determining a value for
maxExtraLoad
is looking at the details of the PDF histogram for request latency, at /admin/histograms. If you choose amaxExtraLoad
of 1.percent, for example, you can expect your p999/p9999 latencies to (roughly) now be that of your p99 latency. For 5.percent, those latencies would shift to your p95 latency. You should also ensure that your backend can tolerate the increased load.- maxExtraLoad
How much extra load, as a Tunable fraction, we are willing to send to the server. Must be between 0.0 and 1.0.
- sendInterrupts
Whether or not to interrupt the original or backup request when a response is returned and the result of the outstanding request is superseded. For protocols without a control plane, where the connection is cut on interrupts, this should be "false" to avoid connection churn.
- minSendBackupAfterMs
Use a minimum non-zero delay to prevent sending unnecessary backup requests immediately for services where the latency at the percentile where a backup will be sent is ~0ms.
- classifier
ResponseClassifier (combined (via ResponseClassifier.orElse) with any existing classifier in the stack params), used for determining whether or not requests have succeeded and should be retried. These determinations are also reflected in stats, and used by FailureAccrualFactory.
- Note
See
idempotent
above for note about low QPS clients and maxExtraLoad
- def idempotent(maxExtraLoad: Double, sendInterrupts: Boolean, classifier: ResponseClassifier): MethodBuilder[Req, Rep]
Configure that requests are to be treated as idempotent.
Configure that requests are to be treated as idempotent. Because requests can be safely retried, BackupRequestFilter is configured with the params maxExtraLoad and sendInterrupts to decrease tail latency by sending an additional fraction of requests.
- maxExtraLoad
How much extra load, as a fraction, we are willing to send to the server. Must be between 0.0 and 1.0.
- sendInterrupts
Whether or not to interrupt the original or backup request when a response is returned and the result of the outstanding request is superseded. For protocols without a control plane, where the connection is cut on interrupts, this should be "false" to avoid connection churn.
- classifier
ResponseClassifier (combined (via ResponseClassifier.orElse) with any existing classifier in the stack params), used for determining whether or not requests have succeeded and should be retried. These determinations are also reflected in stats, and used by FailureAccrualFactory.
- Note
See
idempotent
above for note about low QPS clients and maxExtraLoad
- def idempotent(maxExtraLoad: Double, sendInterrupts: Boolean, minSendBackupAfterMs: Int, classifier: ResponseClassifier): MethodBuilder[Req, Rep]
Configure that requests are to be treated as idempotent.
Configure that requests are to be treated as idempotent. Because requests can be safely retried, BackupRequestFilter is configured with the params
maxExtraLoad
andsendInterrupts
to decrease tail latency by sending an additional fraction of requests.- maxExtraLoad
How much extra load, as a fraction, we are willing to send to the server. Must be between 0.0 and 1.0.
- sendInterrupts
Whether or not to interrupt the original or backup request when a response is returned and the result of the outstanding request is superseded. For protocols without a control plane, where the connection is cut on interrupts, this should be "false" to avoid connection churn.
- minSendBackupAfterMs
Use a minimum non-zero delay to prevent sending unnecessary backup requests immediately for services where the latency at the percentile where a backup will be sent is ~0ms.
- classifier
ResponseClassifier (combined (via ResponseClassifier.orElse) with any existing classifier in the stack params), used for determining whether or not requests have succeeded and should be retried. These determinations are also reflected in stats, and used by FailureAccrualFactory.
- Note
Clients using a maxExtraLoad of 1% will need to get at least 10 QPS in order for any backups to be sent at all because the BackupRequestFilter's retryBudget has a TTL of 10 seconds for deposits (that is, 100 requests need to occur within 10 seconds before a single backup is allowed). The maxExtraLoad can be increased for these clients if they hope to see backups at lower QPS rates.
,See
idempotent
below for a version that takes a Tunable[Double] formaxExtraLoad
.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val methodPool: MethodPool[Req, Rep]
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def newService: Service[Req, Rep]
Create a Service from the current configuration.
- def newService(methodName: String): Service[Req, Rep]
Create a Service from the current configuration.
- def newServicePerEndpoint[ServicePerEndpoint <: Filterable[ServicePerEndpoint]](builder: ServicePerEndpointBuilder[Req, Rep, ServicePerEndpoint], methodName: String): ServicePerEndpoint
Create a ServicePerEndpoint from the current configuration.
- def newServicePerEndpoint[ServicePerEndpoint <: Filterable[ServicePerEndpoint]](builder: ServicePerEndpointBuilder[Req, Rep, ServicePerEndpoint]): ServicePerEndpoint
Create a ServicePerEndpoint from the current configuration.
- def nonIdempotent: MethodBuilder[Req, Rep]
Configure that requests are to be treated as non-idempotent.
Configure that requests are to be treated as non-idempotent. BackupRequestFilter is disabled, and only those failures that are known to be safe to retry (i.e., write failures, where the request was never sent) are retried via requeue filter; any previously configured retries are removed.
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val params: Params
- Definition Classes
- MethodBuilder → Parameterized
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- MethodBuilder → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withParams(ps: Params): MethodBuilder[Req, Rep]
- Definition Classes
- MethodBuilder → Parameterized
- def withRetry: MethodBuilderRetry[Req, Rep]
Configure the application-level retry policy.
Configure the application-level retry policy.
Defaults to using the client's com.twitter.finagle.service.ResponseClassifier to retry failures marked as retryable.
The classifier is also used to determine the logical success metrics of the client. Logical here means after any retries are run. For example should a request result in retryable failure on the first attempt, but succeed upon retry, this is exposed through metrics as a success.
Retrying on
Exception
responses:import com.twitter.finagle.client.MethodBuilder import com.twitter.finagle.service.{ReqRep, ResponseClass} import com.twitter.util.Throw val builder: MethodBuilder[Int, Int] = ??? builder.withRetry.forClassifier { case ReqRep(_, Throw(_)) => ResponseClass.RetryableFailure }
- See also
MethodBuilderRetry
Example: - def withTimeout: MethodBuilderTimeout[Req, Rep]
Configure the timeouts.
Configure the timeouts.
The per-request timeout defaults to using the client's configuration for com.twitter.finagle.service.TimeoutFilter.Param(timeout), which is typically set via com.twitter.finagle.param.CommonParams.withRequestTimeout.
The total timeout defaults to using the client's configuration for com.twitter.finagle.service.TimeoutFilter.TotalTimeout(timeout).
A total timeout of 200 milliseconds:
import com.twitter.conversions.DurationOps._ import com.twitter.finagle.client.MethodBuilder val builder: MethodBuilder[Int, Int] = ??? builder.withTimeout.total(200.milliseconds)
, A per-request timeout of 50 milliseconds:
import com.twitter.conversions.DurationOps._ import com.twitter.finagle.client.MethodBuilder val builder: MethodBuilder[Int, Int] = ??? builder.withTimeout.perRequest(50.milliseconds)
- See also
MethodBuilderTimeout
Examples: - def withTraceInitializer(initializer: TypeAgnostic): MethodBuilder[Req, Rep]
Allow customizations for protocol-specific trace initialization.