Permalink
Browse files

finagle, util: Promote Tunables to public

Summary: Problem / Solution

Tunables have been successfully used internally for a while.
Let's make them public and add a friendlier client configuration
API.

JIRA Issues: CSL-4255

TBR=true

Differential Revision: https://phabricator.twitter.biz/D80751
  • Loading branch information...
jcrossley authored and jenkins committed Aug 16, 2017
1 parent b4e73ee commit f07ebb6475ec38ee8ef77f526c724d98c2b2d95e
View
11 CHANGES
@@ -13,6 +13,12 @@ Note that ``RB_ID=#`` correspond to associated messages in commits.
New Features
~~~~~~~~~~~~
* finagle-core: A `StackClient` can be configured with a `c.t.u.tunable.Tunable`
request timeout using `.withRequestTimeout(tunable)`; this facilitates changing
the timeout at runtime, without server restart.
See https://twitter.github.io/finagle/guide/Configuration.html#tunables for details.
``PHAB_ID=D80751``.
* finagle-core: `SslClientSessionVerifier` and `SslServerSessionVerifier` have been added
as `Stack` params for executing custom SSL/TLS `Session` verification logic on the
establishment of an SSL/TLS `Session`. ``PHAB_ID=D63256``
@@ -82,6 +88,11 @@ New Features
to keep exporting "debug" metrics). Adjust `com.twitter.finagle.stats.verbose` tunable
whitelist to change it. ``PHAB_ID=D79571``
* finagle-tunable: `StandardTunableMap` is now public. Users can access file-based, in-memory,
and service-loaded tunable values using the map.
See https://twitter.github.io/finagle/guide/Configuration.html#tunables for details.
``PHAB_ID=D80751``.
* finagle: Changed dependencies of Netty from 4.1.10 to 4.1.12. ``PHAB_ID=D60438``
Bug Fixes
@@ -236,7 +236,6 @@ on an HTTP client with a `Tunable`:
package com.example.service
import com.twitter.finagle.Http
import com.twitter.finagle.service.TimeoutFilter
import com.twitter.finagle.tunable.StandardTunableMap
import com.twitter.util.Duration
import com.twitter.util.tunable.{Tunable, TunableMap}
@@ -250,7 +249,7 @@ on an HTTP client with a `Tunable`:
val client = Http.client
.withLabel(clientId)
.configured(TimeoutFilter.Param(timeoutTunable))
.withRequestTimeout(timeoutTunable)
.newService("localhost:10000")
Configuration
@@ -28,6 +28,7 @@ scala_library(
exports=[
'util/util-logging',
'util/util-registry',
'util/util-tunable/src/main/scala:scala',
],
fatal_warnings=True,
sources=rglobs('*.scala'),
@@ -3,6 +3,8 @@ package com.twitter.finagle.param
import com.twitter.finagle.service.TimeoutFilter
import com.twitter.finagle.{service, stats, tracing, Stack}
import com.twitter.util
import com.twitter.util.Duration
import com.twitter.util.tunable.Tunable
/**
* A collection of methods for configuring common parameters (labels, stats receivers, etc)
@@ -103,6 +105,33 @@ trait CommonParams[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =
*
* @see [[https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration]]
*/
def withRequestTimeout(timeout: util.Duration): A =
def withRequestTimeout(timeout: Duration): A =
self.configured(TimeoutFilter.Param(timeout))
/**
* 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.
*
* @see [[https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration]] and
* [[https://twitter.github.io/finagle/guide/Configuration.html#tunables]]
*/
def withRequestTimeout(timeout: Tunable[Duration]): A =
self.configured(TimeoutFilter.Param(timeout))
}
@@ -31,7 +31,7 @@ import scala.collection.JavaConverters._
* For more information, see
* [[https://twitter.github.io/finagle/guide/Configuration.html#tunables]].
*/
private[twitter] object StandardTunableMap {
object StandardTunableMap {
private[this] val clientMaps = new ConcurrentHashMap[String, TunableMap]()

0 comments on commit f07ebb6

Please sign in to comment.