public abstract class HttpServerBuilder
extends Object
| Constructor and Description |
|---|
HttpServerBuilder() |
| Modifier and Type | Method and Description |
|---|---|
abstract HttpServerBuilder |
allowDropRequestTrailers(boolean allowDrop)
Provide a hint if request trailers are allowed to
be dropped.
|
HttpServerBuilder |
appendConnectionAcceptorFilter(ConnectionAcceptorFactory factory)
Appends the filter to the chain of filters used to decorate the
ConnectionAcceptor used by this builder. |
HttpServerBuilder |
appendServiceFilter(Predicate<StreamingHttpRequest> predicate,
StreamingHttpServiceFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpService used by this
builder, for every request that passes the provided Predicate. |
HttpServerBuilder |
appendServiceFilter(StreamingHttpServiceFilterFactory factory)
Appends the filter to the chain of filters used to decorate the
StreamingHttpService used by this
builder. |
HttpServerBuilder |
backlog(int backlog)
Deprecated.
Use
listenSocketOption(SocketOption, Object) with key
ServiceTalkSocketOptions.SO_BACKLOG. |
abstract HttpServerBuilder |
bufferAllocator(BufferAllocator allocator)
Sets the
BufferAllocator to be used by this server. |
HttpServerBuilder |
disableDrainingRequestPayloadBody()
Deprecated.
|
protected abstract Single<ServerContext> |
doListen(ConnectionAcceptor connectionAcceptor,
StreamingHttpService service,
HttpExecutionStrategy strategy,
boolean drainRequestPayloadBody)
Deprecated.
This method will be removed. If you depend upon it consider copying the implementation from
DefaultHttpServerBuilder#doListen(ConnectionAcceptor, StreamingHttpService, HttpExecutionStrategy,
boolean) |
HttpServerBuilder |
drainRequestPayloadBody(boolean enable)
Configure automatic consumption of request
payload body when it is not
consumed by the service. |
abstract HttpServerBuilder |
enableWireLogging(String loggerName)
Deprecated.
Use
enableWireLogging(String, LogLevel, BooleanSupplier) instead. |
abstract HttpServerBuilder |
enableWireLogging(String loggerName,
LogLevel logLevel,
BooleanSupplier logUserData)
Enables wire-logging for this server.
|
HttpServerBuilder |
executionStrategy(HttpExecutionStrategy strategy)
Sets the
HttpExecutionStrategy to be used by this server. |
HttpServerBuilder |
executor(Executor executor)
Sets the
Executor to use. |
abstract HttpServerBuilder |
ioExecutor(IoExecutor ioExecutor)
Sets the
IoExecutor to be used by this server. |
HttpServerBuilder |
lifecycleObserver(HttpLifecycleObserver lifecycleObserver)
Sets a
HttpLifecycleObserver that provides visibility into HTTP lifecycle events. |
Single<ServerContext> |
listen(HttpService service)
Starts this server and returns the
ServerContext after the server has been successfully started. |
ServerContext |
listenAndAwait(HttpService service)
Starts this server and returns the
ServerContext after the server has been successfully started. |
Single<ServerContext> |
listenBlocking(BlockingHttpService service)
Starts this server and returns the
ServerContext after the server has been successfully started. |
ServerContext |
listenBlockingAndAwait(BlockingHttpService service)
Starts this server and returns the
ServerContext after the server has been successfully started. |
Single<ServerContext> |
listenBlockingStreaming(BlockingStreamingHttpService service)
Starts this server and returns the
ServerContext after the server has been successfully started. |
ServerContext |
listenBlockingStreamingAndAwait(BlockingStreamingHttpService handler)
Starts this server and returns the
ServerContext after the server has been successfully started. |
abstract <T> HttpServerBuilder |
listenSocketOption(SocketOption<T> option,
T value)
Adds a
SocketOption that is applied to the server socket channel which listens/accepts socket channels. |
Single<ServerContext> |
listenStreaming(StreamingHttpService service)
Starts this server and returns the
ServerContext after the server has been successfully started. |
ServerContext |
listenStreamingAndAwait(StreamingHttpService handler)
Starts this server and returns the
ServerContext after the server has been successfully started. |
abstract HttpServerBuilder |
protocols(HttpProtocolConfig... protocols)
Configurations of various HTTP protocol versions.
|
abstract HttpServerSecurityConfigurator |
secure()
Deprecated.
|
abstract <T> HttpServerBuilder |
socketOption(SocketOption<T> option,
T value)
Adds a
SocketOption that is applied to connected/accepted socket channels. |
abstract HttpServerBuilder |
sslConfig(ServerSslConfig config)
Set the SSL/TLS configuration.
|
abstract HttpServerBuilder |
sslConfig(ServerSslConfig defaultConfig,
Map<String,ServerSslConfig> sniMap)
Set the SSL/TLS and SNI configuration.
|
abstract HttpServerBuilder |
transportObserver(TransportObserver transportObserver)
Sets a
TransportObserver that provides visibility into transport events. |
public abstract HttpServerBuilder protocols(HttpProtocolConfig... protocols)
Note: the order of specified protocols will reflect on priorities for
ALPN in case the connections use
sslConfig(ServerSslConfig).
protocols - HttpProtocolConfig for each protocol that should be supported.this.@Deprecated public HttpServerBuilder backlog(int backlog)
listenSocketOption(SocketOption, Object) with key
ServiceTalkSocketOptions.SO_BACKLOG.backlog - the backlog to use when accepting connections.this.@Deprecated public abstract HttpServerSecurityConfigurator secure()
sslConfig(ServerSslConfig).commit method on the returned
HttpServerSecurityConfigurator will commit the configuration.HttpServerSecurityConfigurator to configure security for this server. It is
mandatory to call any one of the commit methods after all configuration is done.public abstract HttpServerBuilder sslConfig(ServerSslConfig config)
config - The configuration to use.this.public abstract HttpServerBuilder sslConfig(ServerSslConfig defaultConfig, Map<String,ServerSslConfig> sniMap)
defaultConfig - The configuration to use is the client certificate's SNI extension isn't present or the
SNI hostname doesn't match any values in sniMap.sniMap - A map where the keys are matched against the client certificate's SNI extension value in order
to provide the corresponding ServerSslConfig.this.public abstract <T> HttpServerBuilder socketOption(SocketOption<T> option, T value)
SocketOption that is applied to connected/accepted socket channels.T - the type of the value.option - the option to apply.value - the value.StandardSocketOptions,
ServiceTalkSocketOptionspublic abstract <T> HttpServerBuilder listenSocketOption(SocketOption<T> option, T value)
SocketOption that is applied to the server socket channel which listens/accepts socket channels.T - the type of the value.option - the option to apply.value - the value.StandardSocketOptions,
ServiceTalkSocketOptions@Deprecated public abstract HttpServerBuilder enableWireLogging(String loggerName)
enableWireLogging(String, LogLevel, BooleanSupplier) instead.loggerName - The name of the logger to log wire events.this.public abstract HttpServerBuilder enableWireLogging(String loggerName, LogLevel logLevel, BooleanSupplier logUserData)
loggerName - The name of the logger to log wire events.logLevel - The level to log at.logUserData - true to include user data (e.g. data, headers, etc.). false to exclude user
data and log only network events.this.public abstract HttpServerBuilder transportObserver(TransportObserver transportObserver)
TransportObserver that provides visibility into transport events.transportObserver - A TransportObserver that provides visibility into transport events.this.public HttpServerBuilder lifecycleObserver(HttpLifecycleObserver lifecycleObserver)
HttpLifecycleObserver that provides visibility into HTTP lifecycle events.
This method allows setting a HttpLifecycleObserver in a position that captures entire state of the
execution chain, including all filters and internal post-processing. If it's necessary to observe an exchange
after other filters or apply it conditionally, consider using
io.servicetalk.http.netty.HttpLifecycleObserverServiceFilter instead.
lifecycleObserver - A HttpLifecycleObserver that provides visibility into HTTP lifecycle events.this.@Deprecated public HttpServerBuilder disableDrainingRequestPayloadBody()
drainRequestPayloadBody(boolean).payload body when it is not
consumed by the service.
For persistent HTTP connections it is required to
eventually consume the entire request payload to enable reading of the next request. This is required because
requests are pipelined for HTTP/1.1, so if the previous request is not completely read, next request can not be
read from the socket. For cases when there is a possibility that user may forget to consume request payload,
ServiceTalk automatically consumes request payload body. This automatic consumption behavior may create some
overhead and can be disabled using this method when it is guaranteed that all request paths consumes all request
payloads eventually. An example of guaranteed consumption are non-streaming APIs.
this.public HttpServerBuilder drainRequestPayloadBody(boolean enable)
payload body when it is not
consumed by the service.
For persistent HTTP connections it is required to
eventually consume the entire request payload to enable reading of the next request. This is required because
requests are pipelined for HTTP/1.1, so if the previous request is not completely read, next request can not be
read from the socket. For cases when there is a possibility that user may forget to consume request payload,
ServiceTalk automatically consumes request payload body. This automatic consumption behavior may create some
overhead and can be disabled using this method when it is guaranteed that all request paths consumes all request
payloads eventually. An example of guaranteed consumption are non-streaming APIs.
enable - When false it will disable the automatic consumption of request
StreamingHttpRequest.payloadBody().this.public abstract HttpServerBuilder allowDropRequestTrailers(boolean allowDrop)
allowDrop - true if request trailers
are allowed to be dropped.thispublic HttpServerBuilder appendConnectionAcceptorFilter(ConnectionAcceptorFactory factory)
ConnectionAcceptor used by this builder.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.appendConnectionAcceptorFilter(filter1).appendConnectionAcceptorFilter(filter2).
appendConnectionAcceptorFilter(filter3)
accepting a connection by a filter wrapped by this filter chain, the order of invocation of these filters will
be:
filter1 ⇒ filter2 ⇒ filter3
factory - ConnectionAcceptorFactory to append. Lifetime of this
ConnectionAcceptorFactory is managed by this builder and the server started thereof.thispublic HttpServerBuilder appendServiceFilter(StreamingHttpServiceFilterFactory factory)
StreamingHttpService used by this
builder.
Note this method will be used to decorate the StreamingHttpService passed to
listenStreaming(StreamingHttpService) before it is used by the server.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
accepting a request by a service wrapped by this filter chain, the order of invocation of these filters will be:
filter1 ⇒ filter2 ⇒ filter3 ⇒ service
factory - StreamingHttpServiceFilterFactory to append.thispublic HttpServerBuilder appendServiceFilter(Predicate<StreamingHttpRequest> predicate, StreamingHttpServiceFilterFactory factory)
StreamingHttpService used by this
builder, for every request that passes the provided Predicate.
Note this method will be used to decorate the StreamingHttpService passed to
listenStreaming(StreamingHttpService) before it is used by the server.
The order of execution of these filters are in order of append. If 3 filters are added as follows:
builder.append(filter1).append(filter2).append(filter3)
accepting a request by a service wrapped by this filter chain, the order of invocation of these filters will be:
filter1 ⇒ filter2 ⇒ filter3 ⇒ service
predicate - the Predicate to test if the filter must be applied.factory - StreamingHttpServiceFilterFactory to append.thispublic abstract HttpServerBuilder ioExecutor(IoExecutor ioExecutor)
IoExecutor to be used by this server.ioExecutor - IoExecutor to use.this.public HttpServerBuilder executor(Executor executor)
Executor to use.executor - Executor to use.this.public abstract HttpServerBuilder bufferAllocator(BufferAllocator allocator)
BufferAllocator to be used by this server.allocator - BufferAllocator to use.this.public HttpServerBuilder executionStrategy(HttpExecutionStrategy strategy)
HttpExecutionStrategy to be used by this server.strategy - HttpExecutionStrategy to use by this server.this.public ServerContext listenAndAwait(HttpService service) throws Exception
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
service - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.ServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public ServerContext listenStreamingAndAwait(StreamingHttpService handler) throws Exception
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
handler - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.ServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public ServerContext listenBlockingAndAwait(BlockingHttpService service) throws Exception
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
service - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.ServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public ServerContext listenBlockingStreamingAndAwait(BlockingStreamingHttpService handler) throws Exception
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
handler - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.ServerContext by blocking the calling thread until the server is successfully started or
throws an Exception if the server could not be started.Exception - if the server could not be started.public Single<ServerContext> listen(HttpService service)
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
service - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public Single<ServerContext> listenStreaming(StreamingHttpService service)
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
service - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public Single<ServerContext> listenBlocking(BlockingHttpService service)
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
service - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.public Single<ServerContext> listenBlockingStreaming(BlockingStreamingHttpService service)
ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this will result in a socket bind/listen on address.
service - Service invoked for every request received by this server. The returned ServerContext
manages the lifecycle of the service, ensuring it is closed when the ServerContext is closed.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.@Deprecated
protected abstract Single<ServerContext> doListen(@Nullable
ConnectionAcceptor connectionAcceptor,
StreamingHttpService service,
HttpExecutionStrategy strategy,
boolean drainRequestPayloadBody)
DefaultHttpServerBuilder#doListen(ConnectionAcceptor, StreamingHttpService, HttpExecutionStrategy,
boolean)ServerContext after the server has been successfully started.
If the underlying protocol (eg. TCP) supports it this should result in a socket bind/listen on address.
connectionAcceptor - ConnectionAcceptor to use for the server.service - StreamingHttpService to use for the server.strategy - the HttpExecutionStrategy to use for the service.drainRequestPayloadBody - if true the server implementation should automatically subscribe and
ignore the payload body of incoming requests.Single that completes when the server is successfully started or terminates with an error if
the server could not be started.