package builder
- Alphabetic
- Public
- All
Type Members
- class ClientBuilder[Req, Rep, HasCluster, HasCodec, HasHostConnectionLimit] extends AnyRef
A builder of Finagle Clients.
A builder of Finagle Clients.
Please see the user guide for information on the preferred
with
-style and MethodBuilder client-construction APIs.val client = ClientBuilder() .stack(Http.client) .hosts("localhost:10000,localhost:10001,localhost:10003") .hostConnectionLimit(1) .tcpConnectTimeout(1.second) // max time to spend establishing a TCP connection. .retries(2) // (1) per-request retries .reportTo(DefaultStatsReceiver) // export host-level load data to the loaded-StatsReceiver .build()
The
ClientBuilder
requires the definition ofcluster
,stack
, andhostConnectionLimit
. In Scala, these are statically type checked, and in Java the lack of any of the above causes a runtime error.The
build
method uses an implicit argument to statically typecheck the builder (to ensure completeness, see above). The Java compiler cannot provide such implicit, so we provide a separate function in Java to accomplish this. Thus, the Java code for the above isService<HttpRequest, HttpResponse> service = ClientBuilder.safeBuild( ClientBuilder.get() .stack(Http.client()) .hosts("localhost:10000,localhost:10001,localhost:10003") .hostConnectionLimit(1) .tcpConnectTimeout(1.second) .retries(2) .reportTo(DefaultStatsReceiver)
Alternatively, using the
unsafeBuild
method onClientBuilder
verifies the builder dynamically, resulting in a runtime error instead of a compiler error.Defaults
The following defaults are applied to clients constructed via ClientBuilder, unless overridden with the corresponding method. These defaults were chosen carefully so as to work well for most use cases.
Commonly-configured options:
connectTimeout
: Duration.ToptcpConnectTimeout
: 1 secondrequestTimeout
: Duration.Toptimeout
: Duration.TophostConnectionLimit
:Int.MaxValue
hostConnectionCoresize
: 0hostConnectionIdleTime
: Duration.TophostConnectionMaxWaiters
:Int.MaxValue
failFast
: truefailureAccrualParams
,failureAccrualFactory
:numFailures
= 5,markDeadFor
= 5 seconds
Advanced options:
Before changing any of these, make sure that you know exactly how they will affect your application -- these options are typically only changed by expert users.
keepAlive
: Unspecified, in which case the Java default offalse
is usedhostConnectionMaxIdleTime
: Duration.TophostConnectionMaxLifeTime
: Duration.Top
- See also
The user guide for information on the preferred
with
-style and MethodBuilder client-construction APIs.
- trait ClientConfigEvidence[HasCluster, HasCodec, HasHostConnectionLimit] extends AnyRef
- Annotations
- @implicitNotFound("Builder is not fully configured: Cluster: ${HasCluster}, Codec: ${HasCodec}, HostConnectionLimit: ${HasHostConnectionLimit}")
- class IncompleteSpecification extends Exception
Used by builder to throw exceptions if the specification is incomplete.
Used by builder to throw exceptions if the specification is incomplete.
if (!_codec.isDefined) throw new IncompleteSpecification("No codec was specified")
- class ServerBuilder[Req, Rep, HasCodec, HasBindTo, HasName] extends AnyRef
A handy Builder for constructing Servers (i.e., binding Services to a port).
A handy Builder for constructing Servers (i.e., binding Services to a port). This class is subclassable. Override copy() and build() to do your own dirty work.
Please see the Finagle user guide for information on the preferred
with
-style client-construction APIs.The main class to use is com.twitter.finagle.builder.ServerBuilder, as so
ServerBuilder() .stack(Http.server) .hostConnectionMaxLifeTime(5.minutes) .readTimeout(2.minutes) .name("servicename") .bindTo(new InetSocketAddress(serverPort)) .build(plusOneService)
The
ServerBuilder
requires the definition ofstack
,bindTo
andname
. In Scala, these are statically type checked, and in Java the lack of any of the above causes a runtime error.The
build
method uses an implicit argument to statically typecheck the builder (to ensure completeness, see above). The Java compiler cannot provide such implicit, so we provide a separate function in Java to accomplish this. Thus, the Java code for the above isServerBuilder.safeBuild( plusOneService, ServerBuilder.get() .stack(Http.server()) .hostConnectionMaxLifeTime(5.minutes) .readTimeout(2.minutes) .name("servicename") .bindTo(new InetSocketAddress(serverPort)));
Alternatively, using the
unsafeBuild
method onServerBuilder
verifies the builder dynamically, resulting in a runtime error instead of a compiler error.Defaults
The following defaults are applied to servers constructed via ServerBuilder, unless overridden with the corresponding method. These defaults were chosen carefully so as to work well for most use cases. Before changing any of them, make sure that you know exactly how they will affect your application -- these options are typically only changed by expert users.
-
openConnectionsThresholds
: None -maxConcurrentRequests
: Int.MaxValue -backlog
: OS-defined default value- See also
The user guide for information on the preferred
with
-style APIs insead.
- trait ServerConfigEvidence[HasCodec, HasBindTo, HasName] extends AnyRef
- Annotations
- @implicitNotFound("Builder is not fully configured: Codec: ${HasCodec}, BindTo: ${HasBindTo}, Name: ${HasName}")
- class SourceTrackingMonitor extends Monitor
A monitor that unrolls the exception causes to report source information if any
Value Members
- object ClientBuilder
Factory for com.twitter.finagle.builder.ClientBuilder instances
- object ClientConfig
- object ServerBuilder
Factory for com.twitter.finagle.builder.ServerBuilder instances
- object ServerConfig