In this milestone, we’ve been focusing on two major directions:
There is a new user-friendly API for configuring Finagle clients and servers using with
-prefixed
methods (.withClientId
, .withStatsReceiver
, etc). Discoverable configuration parameters are a
modern alternative to ClientBuilder/ServerBuilder which provides an easy to use, type safe, and IDE
discoverable API on top of $Protocol.{client,server}.configured
through a collection of
with
-prefixed methods available on both clients and servers. It’s already in master and we
encourage you to open your favorite IDE and type client.with
or server.with
and start discovering.
Example:
import com.twitter.finagle.Http
import com.twitter.conversions.time._
Http.client
.withLabel("http-client")
.withSessionQualifier.noFailFast
.withSession.acquisitionTimeout(10.seconds)
See it in action!
We thought carefully about how to make these clear and easy to use. If you’re curious about the design, please feel free to take a look at the design principles.
The new API is fully documented so that every method has an up-to-date scaladoc comment explaining the parameters it configures as well as mentioning their default values.
Also, it’s worth mentioning that this API is 100% Java-friendly. You can now forget about
new Param(...).mk(...)
and focus on what’s important–values, not the wrappers around them.
We updated/reworked Finagle’s User Guide recently to capture the current state of Finagle. For example, we updated both Clients and Servers with example configurations of their modules.
Finagle’s new response classifiers improve client’s avoidance of faulty nodes, and thus, increase your success rate. To get this benefit, you must wire up the application’s rules into your clients. There are already basic classifiers in Finagle available for HTTP and Thrift.
For example, the following configuration advises a Finagle client treat 500s HTTP responses as non-retriable failures.
import com.twitter.finagle.Http
import com.twitter.finagle.http.service.HttpResponseClassifier
Http.client
.withResponseClassifier(HttpResponseClassifier.ServerErrorsAsFailures)
As part of our work on client-side admission control, there is a new client module maintaining the limit of pending requests (i.e., requests that haven’t been yet written to a wire). The limit is unbounded by default.
In the following example, an HTTP client is configured to have at most 100 pending requests in the queue. All requests on top of 100 will be rejected by a client.
import com.twitter.finagle.Http
Http.client
.withAdmissionControl.maxPendingRequests(100)