To migrate to the Stack-based APIs, use Server.serve
.
To migrate to the Stack-based APIs, use Server.serve
.
For example:
import com.twitter.finagle.Http import com.twitter.finagle.Service val service: Service[Req, Rep] = ??? Http.server.serve(address, service)
Construct the Server, given the provided ServiceFactory.
Construct the Server, given the provided ServiceFactory. This is useful if the protocol is stateful (e.g., requires authentication or supports transactions).
Construct the Server, given the provided Service.
Cancel pending futures whenever the the connection is shut down.
Cancel pending futures whenever the the connection is shut down. This defaults to true.
To migrate to the Stack-based APIs, use configured
.
For example:
import com.twitter.finagle.Http import com.twitter.finagle.filter.MaskCancelFilter Http.server.configured(MaskCancelFilter.Param(!yesOrNo))
com.twitter.finagle.filter.ServerAdmissionControl
Java friendly API for configuring the underlying Params.
Java friendly API for configuring the underlying Params.
Configures the server with a given param represented
as the tuple (param value, stack param instance)
The Tuple2
can often be created by calls to a mk(): (P, Stack.Param[P])
method on parameters (see
com.twitter.finagle.loadbalancer.LoadBalancerFactory.Param.mk()
as an example).
Configure the underlying Params.
Configure the underlying Params.
Configures the server with a given param
Java users may find it easier to use the Tuple2
version below.
When true, the server is daemonized.
When true, the server is daemonized. As with java threads, a process can only exit only when all remaining servers are daemonized. False by default.
The default for the Stack-based APIs is for the server to be daemonized.
Configure admission control filters in the server Stack.
Configure admission control filters in the server Stack.
To migrate to the Stack-based APIs, use configured
.
For example:
import com.twitter.finagle.Http import com.twitter.finagle.filter.ServerAdmissionControl Http.server.configured(ServerAdmissionControl.Param(enable))
com.twitter.finagle.filter.ServerAdmissionControl
Provide an alternative to putting all request exceptions under a "failures" stat.
Provide an alternative to putting all request exceptions under a "failures" stat. Typical implementations may report any cancellations or validation errors separately so success rate considers only valid non cancelled requests.
To migrate to the Stack-based APIs, use CommonParams.withExceptionStatsHandler
.
For example:
import com.twitter.finagle.Http
Http.server.withExceptionStatsHandler(exceptionStatsHandler)
function to record failure details.
To migrate to the Stack-based APIs, use ServerTransportParams.verbose
.
To migrate to the Stack-based APIs, use ServerTransportParams.verbose
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.verbose
To migrate to the Stack-based APIs, use configured
.
To migrate to the Stack-based APIs, use configured
.
For example:
import com.twitter.finagle.Http import com.twitter.finagle.param Http.server.configured(param.Logger(logger))
Configures the maximum concurrent requests that are admitted by the server at any given time.
Configures the maximum concurrent requests that are admitted
by the server at any given time. If the server receives a
burst of traffic that exceeds this limit, the burst is rejected
with a FailureFlags.Rejected
exception. Note, this failure signals
a graceful rejection which is transmitted to clients by certain
protocols in Finagle (e.g. Http, ThriftMux). The limit is global
to all sessions.
To migrate to the Stack-based APIs, use ServerAdmissionControlParams.concurrencyLimit
.
For example:
import com.twitter.finagle.Http Http.server.withAdmissionControl.concurrencyLimit(10, 0)
To migrate to the Stack-based APIs, use CommonParams.withMonitor
.
To migrate to the Stack-based APIs, use CommonParams.withMonitor
.
For example:
import com.twitter.finagle.Http import com.twitter.util.Monitor val monitor: Monitor = ??? Http.server.withMonitor(monitor)
To migrate to the Stack-based APIs, use CommonParams.withLabel
.
To migrate to the Stack-based APIs, use CommonParams.withLabel
.
For example:
import com.twitter.finagle.Http Http.server.withLabel("my_server")
The underlying Params used for configuration.
To migrate to the Stack-based APIs, use TransportParams.readTimeout
.
To migrate to the Stack-based APIs, use TransportParams.readTimeout
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.readTimeout(howlong)
To migrate to the Stack-based APIs, use ServerTransportParams.receiveBufferSize
.
To migrate to the Stack-based APIs, use ServerTransportParams.receiveBufferSize
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.receiveBufferSize(value)
To migrate to the Stack-based APIs, use CommonParams.withStatsReceiver
.
To migrate to the Stack-based APIs, use CommonParams.withStatsReceiver
.
For example:
import com.twitter.finagle.Http
Http.server.withStatsReceiver(receiver)
To migrate to the Stack-based APIs, use CommonParams.withRequestTimeout
.
To migrate to the Stack-based APIs, use CommonParams.withRequestTimeout
.
For example:
import com.twitter.finagle.Http
Http.server.withRequestTimeout(howlong)
if the request is not complete after howlong
, the work that is
in progress will be interrupted via Future.raise.
The currently configured com.twitter.finagle.service.ResponseClassifier.
The currently configured com.twitter.finagle.service.ResponseClassifier.
If unspecified, the default classifier is com.twitter.finagle.service.ResponseClassifier.Default.
Configure a com.twitter.finagle.service.ResponseClassifier which is used to determine the result of a request/response.
Configure a com.twitter.finagle.service.ResponseClassifier which is used to determine the result of a request/response.
This allows developers to give Finagle the additional application-specific knowledge necessary in order to properly classify responses. Without this, Finagle cannot make judgements about application-level failures as it only has a narrow understanding of failures (for example: transport level, timeouts, and nacks).
As an example take an HTTP server that returns a response with a 500 status code. To Finagle this is a successful request/response. However, the application developer may want to treat all 500 status codes as failures and can do so via setting a com.twitter.finagle.service.ResponseClassifier.
ResponseClassifier is a PartialFunction and as such multiple classifiers can be composed together via PartialFunction.orElse.
Response classification is independently configured on the client and server.
For client-side response classification using com.twitter.finagle.builder.ClientBuilder,
see com.twitter.finagle.builder.ClientBuilder.responseClassifier
To migrate to the Stack-based APIs, use CommonParams.withResponseClassifier
.
For example:
import com.twitter.finagle.Http
Http.server.withResponseClassifier(classifier)
If unspecified, the default classifier is com.twitter.finagle.service.ResponseClassifier.Default which is a total function fully covering the input domain.
com.twitter.finagle.http.service.HttpResponseClassifier for some HTTP classification tools.
To migrate to the Stack-based APIs, use ServerTransportParams.sendBufferSize
.
To migrate to the Stack-based APIs, use ServerTransportParams.sendBufferSize
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.sendBufferSize(value)
Overrides the stack and com.twitter.finagle.Server that will be used by this builder.
Overrides the stack and com.twitter.finagle.Server that will be used by this builder.
A StackBasedServer representation of a
com.twitter.finagle.Server. server
is materialized with the state of
configuration when build
is called. There is no guarantee that all
builder parameters will be used by the resultant Server
; it is up to the
discretion of server
itself and the protocol implementation.
Encrypt the connection with SSL/TLS.
Encrypt the connection with SSL/TLS.
To migrate to the Stack-based APIs, use ServerTransportParams.tls
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.tls(...)
Encrypt the connection with SSL/TLS.
Encrypt the connection with SSL/TLS.
To migrate to the Stack-based APIs, use ServerTransportParams.tls
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.tls(config, engineFactory, sessionVerifier)
Encrypt the connection with SSL/TLS.
Encrypt the connection with SSL/TLS.
To migrate to the Stack-based APIs, use ServerTransportParams.tls
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.tls(config, sessionVerifier)
Encrypt the connection with SSL/TLS.
Encrypt the connection with SSL/TLS.
To migrate to the Stack-based APIs, use ServerTransportParams.tls
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.tls(config, engineFactory)
Encrypt the connection with SSL/TLS.
Encrypt the connection with SSL/TLS.
To migrate to the Stack-based APIs, use ServerTransportParams.tls
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.tls(config)
To migrate to the Stack-based APIs, use CommonParams.withTracer
.
To migrate to the Stack-based APIs, use CommonParams.withTracer
.
For example:
import com.twitter.finagle.Http
Http.server.withTracer(t)
Configures the traffic class.
Configures the traffic class.
To migrate to the Stack-based APIs, use configured
.
For example:
import com.twitter.finagle.Http import com.twitter.finagle.server.Listener Http.server.configured(Listener.TrafficClass(value))
Listener.TrafficClass
Construct a Service, with runtime checks for builder completeness.
To migrate to the Stack-based APIs, use TransportParams.writeTimeout
.
To migrate to the Stack-based APIs, use TransportParams.writeTimeout
.
For example:
import com.twitter.finagle.Http
Http.server.withTransport.writeTimeout(howlong)
(Since version 5.0.1) Used for ABI compat
Construct the Server, given the provided ServiceFactory.
Construct the Server, given the provided ServiceFactory. This is useful if the protocol is stateful (e.g., requires authentication or supports transactions).
(Since version 5.0.1) Use the ServiceFactory variant instead
Construct the Server, given the provided Service factory.
Construct the Server, given the provided Service factory.
(Since version 5.0.1) Use the ServiceFactory variant instead
(Since version 5.0.1) Used for ABI compat
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
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 isAlternatively, 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 valueThe user guide for information on the preferred
with
-style APIs insead.