public abstract class GrpcServerBuilder
extends java.lang.Object
Constructor and Description |
---|
GrpcServerBuilder() |
Modifier and Type | Method and Description |
---|---|
abstract GrpcServerBuilder |
appendConnectionAcceptorFilter(ConnectionAcceptorFactory factory)
Append the filter to the chain of filters used to decorate the
ConnectionAcceptor used by this builder. |
GrpcServerBuilder |
appendHttpServiceFilter(java.util.function.Predicate<StreamingHttpRequest> predicate,
StreamingHttpServiceFilterFactory factory)
Append the filter to the chain of filters used to decorate the service used by this builder, for every request
that passes the provided
Predicate . |
GrpcServerBuilder |
appendHttpServiceFilter(StreamingHttpServiceFilterFactory factory)
Append the filter to the chain of filters used to decorate the service used by this builder.
|
abstract GrpcServerBuilder |
backlog(int backlog)
The maximum queue length for incoming connection indications (a request to connect) is set to the backlog
parameter.
|
abstract GrpcServerBuilder |
bufferAllocator(BufferAllocator allocator)
Sets the
BufferAllocator to be used by this server. |
abstract GrpcServerBuilder |
disableDrainingRequestPayloadBody()
Disables automatic consumption of request
payload body when it is not
consumed by the service. |
protected abstract void |
doAppendHttpServiceFilter(java.util.function.Predicate<StreamingHttpRequest> predicate,
StreamingHttpServiceFilterFactory factory)
Append the filter to the chain of filters used to decorate the service used by this builder, for every request
that passes the provided
Predicate . |
protected abstract void |
doAppendHttpServiceFilter(StreamingHttpServiceFilterFactory factory)
Append the filter to the chain of filters used to decorate the service used by this builder.
|
protected abstract Single<ServerContext> |
doListen(GrpcServiceFactory<?,?,?> serviceFactory)
Starts this server and returns the
ServerContext after the server has been successfully started. |
abstract GrpcServerBuilder |
enableWireLogging(java.lang.String loggerName)
Enable wire-logging for this server.
|
abstract GrpcServerBuilder |
executionStrategy(GrpcExecutionStrategy strategy)
Sets the
HttpExecutionStrategy to be used by this server. |
abstract GrpcServerBuilder |
ioExecutor(IoExecutor ioExecutor)
Sets the
IoExecutor to be used by this server. |
Single<ServerContext> |
listen(GrpcServiceFactory<?,?,?>... serviceFactories)
Starts this server and returns the
ServerContext after the server has been successfully started. |
ServerContext |
listenAndAwait(GrpcServiceFactory<?,?,?>... serviceFactories)
Starts this server and returns the
ServerContext after the server has been successfully started. |
abstract GrpcServerBuilder |
protocols(HttpProtocolConfig... protocols)
Configurations of various underlying protocol versions.
|
abstract GrpcServerSecurityConfigurator |
secure()
Initiate security configuration for this server.
|
abstract GrpcServerSecurityConfigurator |
secure(java.lang.String... sniHostnames)
Initiate security configuration for this server for the passed
sniHostnames . |
abstract <T> GrpcServerBuilder |
socketOption(java.net.SocketOption<T> option,
T value)
Add a
SocketOption that is applied. |
public abstract GrpcServerBuilder protocols(HttpProtocolConfig... protocols)
Note: the order of specified protocols will reflect on priorities for ALPN in case the connections are
secured
.
protocols
- HttpProtocolConfig
for each protocol that should be supported.this
.public abstract GrpcServerBuilder backlog(int backlog)
backlog
- the backlog to use when accepting connections.this
.public abstract GrpcServerSecurityConfigurator secure()
commit
method on the returned
GrpcServerSecurityConfigurator
will commit the configuration.
Additionally use secure(String...)
to define configurations for specific
SNI hostnames. If such configuration is additionally
defined then configuration using this method is used as default if the hostname does not match any of the
specified hostnames.
GrpcServerSecurityConfigurator
to configure security for this server. It is
mandatory to call any one of the commit
methods after all configuration is done.public abstract GrpcServerSecurityConfigurator secure(java.lang.String... sniHostnames)
sniHostnames
.
Calling any commit
method on the returned GrpcServerSecurityConfigurator
will commit the
configuration.
When using this method, it is mandatory to also define the default configuration using secure()
which
is used when the hostname does not match any of the specified sniHostnames
.
sniHostnames
- SNI hostnames for which this
config is being defined.GrpcServerSecurityConfigurator
to configure security for this server. It is
mandatory to call any one of the commit
methods after all configuration is done.public abstract <T> GrpcServerBuilder socketOption(java.net.SocketOption<T> option, T value)
SocketOption
that is applied.T
- the type of the value.option
- the option to apply.value
- the value.this
.StandardSocketOptions
,
ServiceTalkSocketOptions
public abstract GrpcServerBuilder enableWireLogging(java.lang.String loggerName)
loggerName
- The name of the logger to log wire events.this
.public abstract GrpcServerBuilder disableDrainingRequestPayloadBody()
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 abstract GrpcServerBuilder 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.this
.public final GrpcServerBuilder appendHttpServiceFilter(StreamingHttpServiceFilterFactory factory)
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.this
.public final GrpcServerBuilder appendHttpServiceFilter(java.util.function.Predicate<StreamingHttpRequest> predicate, StreamingHttpServiceFilterFactory factory)
Predicate
.
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.this
.public abstract GrpcServerBuilder ioExecutor(IoExecutor ioExecutor)
IoExecutor
to be used by this server.ioExecutor
- IoExecutor
to use.this
.public abstract GrpcServerBuilder bufferAllocator(BufferAllocator allocator)
BufferAllocator
to be used by this server.allocator
- BufferAllocator
to use.this
.public abstract GrpcServerBuilder executionStrategy(GrpcExecutionStrategy strategy)
HttpExecutionStrategy
to be used by this server.strategy
- HttpExecutionStrategy
to use by this server.this
.public final Single<ServerContext> listen(GrpcServiceFactory<?,?,?>... serviceFactories)
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
.
serviceFactories
- GrpcServiceFactory
(s) to create a gRPC service.Single
that completes when the server is successfully started or terminates with an error if
the server could not be started.public final ServerContext listenAndAwait(GrpcServiceFactory<?,?,?>... serviceFactories) throws java.lang.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
.
serviceFactories
- GrpcServiceFactory
(s) to create a gRPC service.ServerContext
by blocking the calling thread until the server is successfully started or
throws an Exception
if the server could not be started.java.lang.Exception
- if the server could not be started.protected abstract Single<ServerContext> doListen(GrpcServiceFactory<?,?,?> serviceFactory)
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
.
serviceFactory
- GrpcServiceFactory
to create a gRPC service.ServerContext
by blocking the calling thread until the server is successfully started or
throws an Exception
if the server could not be started.protected abstract void doAppendHttpServiceFilter(StreamingHttpServiceFilterFactory factory)
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.protected abstract void doAppendHttpServiceFilter(java.util.function.Predicate<StreamingHttpRequest> predicate, StreamingHttpServiceFilterFactory factory)
Predicate
.
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.