Package io.micronaut.grpc.server
Class GrpcServerConfiguration
java.lang.Object
io.micronaut.grpc.server.GrpcServerConfiguration
Configuration for the GRPC server.
- Since:
- 1.0
- Author:
- graemerocher, Iván López
-
Field Summary
-
Constructor Summary
ConstructorDescriptionGrpcServerConfiguration
(io.micronaut.context.env.Environment environment, @Nullable String serverHost, @Nullable Integer serverPort, ExecutorService executorService, io.micronaut.core.io.ResourceResolver resourceResolver) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionGets the maximum duration application will wait for the server to terminate and release all resources.@NonNull String
The instance id.@NonNull io.grpc.ServerBuilder<?>
The server builder.@NonNull GrpcSslConfiguration
The SSL configuration.The server host.int
The server port.boolean
isSecure()
Whether SSL is used.void
setAwaitTermination
(Duration awaitTermination) Sets the maximum duration application will wait for the server to terminate and release all resources.void
setInstanceId
(String instanceId) Sets the instance id name used for registering the GRPC service in Service Discovery.void
setMaxInboundMessageSize
(int bytes) Sets the maximum message size allowed to be received on the server.void
setMaxInboundMetadataSize
(int bytes) Sets the maximum size of metadata allowed to be received.void
setServerConfiguration
(GrpcSslConfiguration sslConfiguration) Sets the SSL configuration.
-
Field Details
-
PREFIX
- See Also:
-
PORT
- See Also:
-
HOST
- See Also:
-
ENABLED
- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
DEFAULT_AWAIT_TERMINATION
-
serverBuilder
@ConfigurationBuilder(prefixes="", excludes="protocolNegotiator") protected final io.grpc.netty.NettyServerBuilder serverBuilder
-
-
Constructor Details
-
GrpcServerConfiguration
public GrpcServerConfiguration(io.micronaut.context.env.Environment environment, @Property(name="grpc.server.host") @Nullable @Nullable String serverHost, @Property(name="grpc.server.port") @Nullable @Nullable Integer serverPort, @Named("io") ExecutorService executorService, io.micronaut.core.io.ResourceResolver resourceResolver) Default constructor.- Parameters:
environment
- The environmentserverHost
- The server hostserverPort
- The server portexecutorService
- The IO executor serviceresourceResolver
- The resource resolver
-
-
Method Details
-
isSecure
public boolean isSecure()Whether SSL is used.- Returns:
- True if SSL is used
-
getServerBuilder
@NonNull public @NonNull io.grpc.ServerBuilder<?> getServerBuilder()The server builder.- Returns:
- The
ServerBuilder
-
getServerHost
The server host.- Returns:
- The server host
-
getServerPort
public int getServerPort()The server port.- Returns:
- The server port
-
getInstanceId
The instance id.- Returns:
- The instance id
-
setInstanceId
Sets the instance id name used for registering the GRPC service in Service Discovery. If this is not set, the application name will be used.- Parameters:
instanceId
- The instance id
-
setMaxInboundMessageSize
public void setMaxInboundMessageSize(@ReadableBytes int bytes) Sets the maximum message size allowed to be received on the server. If not called, defaults to 4 MiB. The default provides protection to servers who haven't considered the possibility of receiving large messages while trying to be large enough to not be hit in normal usage.This method is advisory, and implementations may decide to not enforce this. Currently, the only known transport to not enforce this is
InProcessServer
.- Parameters:
bytes
- the maximum number of bytes a single message can be.- Throws:
IllegalArgumentException
- if bytes is negative.UnsupportedOperationException
- if unsupported.- Since:
- 1.13.0
-
setMaxInboundMetadataSize
public void setMaxInboundMetadataSize(@ReadableBytes int bytes) Sets the maximum size of metadata allowed to be received.Integer.MAX_VALUE
disables the enforcement. The default is implementation-dependent, but is not generally less than 8 KiB and may be unlimited.This is cumulative size of the metadata. The precise calculation is implementation-dependent, but implementations are encouraged to follow the calculation used for HTTP/2's SETTINGS_MAX_HEADER_LIST_SIZE. It sums the bytes from each entry's key and value, plus 32 bytes of overhead per entry.
- Parameters:
bytes
- the maximum size of received metadata- Throws:
IllegalArgumentException
- if bytes is non-positive- Since:
- 1.17.0
-
getServerConfiguration
The SSL configuration.- Returns:
- The SSL configuration
-
setAwaitTermination
Sets the maximum duration application will wait for the server to terminate and release all resources.- Parameters:
awaitTermination
- The maximum duration the application will wait for the server to terminate.
-
getAwaitTermination
Gets the maximum duration application will wait for the server to terminate and release all resources.- Returns:
- The maximum duration the application will wait for the server to terminate.
-
setServerConfiguration
Sets the SSL configuration.- Parameters:
sslConfiguration
- The server configuration
-