Package io.micronaut.grpc.server
Class GrpcServerConfiguration
- java.lang.Object
-
- io.micronaut.grpc.server.GrpcServerConfiguration
-
@ConfigurationProperties("grpc.server") public class GrpcServerConfiguration extends java.lang.ObjectConfiguration for the GRPC server.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.time.DurationDEFAULT_AWAIT_TERMINATIONstatic intDEFAULT_PORTstatic java.lang.StringENABLEDstatic java.lang.StringHEALTH_ENABLEDDeprecated.static java.lang.StringHOSTstatic java.lang.StringPORTstatic java.lang.StringPREFIXprotected io.grpc.netty.NettyServerBuilderserverBuilder
-
Constructor Summary
Constructors Constructor Description GrpcServerConfiguration(io.micronaut.context.env.Environment environment, java.lang.String serverHost, java.lang.Integer serverPort, java.util.concurrent.ExecutorService executorService)Deprecated.GrpcServerConfiguration(io.micronaut.context.env.Environment environment, java.lang.String serverHost, java.lang.Integer serverPort, java.util.concurrent.ExecutorService executorService, io.micronaut.core.io.ResourceResolver resourceResolver)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.DurationgetAwaitTermination()Gets the maximum duration application will wait for the server to terminate and release all resources.java.lang.StringgetInstanceId()The instance id.io.grpc.ServerBuilder<?>getServerBuilder()The server builder.GrpcSslConfigurationgetServerConfiguration()The SSL configuration.java.util.Optional<java.lang.String>getServerHost()The server host.intgetServerPort()The server port.booleanisSecure()Whether SSL is used.voidsetAwaitTermination(java.time.Duration awaitTermination)Sets the maximum duration application will wait for the server to terminate and release all resources.voidsetInstanceId(java.lang.String instanceId)Sets the instance id name used for registering the GRPC service in Service Discovery.voidsetMaxInboundMessageSize(int bytes)Sets the maximum message size allowed to be received on the server.voidsetMaxInboundMetadataSize(int bytes)Sets the maximum size of metadata allowed to be received.voidsetServerConfiguration(GrpcSslConfiguration sslConfiguration)Sets the SSL configuration.
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
PORT
public static final java.lang.String PORT
- See Also:
- Constant Field Values
-
HOST
public static final java.lang.String HOST
- See Also:
- Constant Field Values
-
ENABLED
public static final java.lang.String ENABLED
- See Also:
- Constant Field Values
-
HEALTH_ENABLED
@Deprecated public static final java.lang.String HEALTH_ENABLED
Deprecated.- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
- See Also:
- Constant Field Values
-
DEFAULT_AWAIT_TERMINATION
public static final java.time.Duration DEFAULT_AWAIT_TERMINATION
-
serverBuilder
@ConfigurationBuilder(prefixes="", excludes="protocolNegotiator") protected final io.grpc.netty.NettyServerBuilder serverBuilder
-
-
Constructor Detail
-
GrpcServerConfiguration
@Deprecated public GrpcServerConfiguration(io.micronaut.context.env.Environment environment, @Property(name="grpc.server.host") @Nullable java.lang.String serverHost, @Property(name="grpc.server.port") @Nullable java.lang.Integer serverPort, @Named("io") java.util.concurrent.ExecutorService executorService)Deprecated.Constructor.- Parameters:
environment- The environmentserverHost- The server hostserverPort- The server portexecutorService- The IO executor service
-
GrpcServerConfiguration
@Creator public GrpcServerConfiguration(io.micronaut.context.env.Environment environment, @Property(name="grpc.server.host") @Nullable java.lang.String serverHost, @Property(name="grpc.server.port") @Nullable java.lang.Integer serverPort, @Named("io") java.util.concurrent.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 Detail
-
isSecure
public boolean isSecure()
Whether SSL is used.- Returns:
- True if SSL is used
-
getServerBuilder
@NonNull public io.grpc.ServerBuilder<?> getServerBuilder()
The server builder.- Returns:
- The
ServerBuilder
-
getServerHost
public java.util.Optional<java.lang.String> getServerHost()
The server host.- Returns:
- The server host
-
getServerPort
public int getServerPort()
The server port.- Returns:
- The server port
-
getInstanceId
@NonNull public java.lang.String getInstanceId()
The instance id.- Returns:
- The instance id
-
setInstanceId
public void setInstanceId(java.lang.String instanceId)
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:
java.lang.IllegalArgumentException- if bytes is negative.java.lang.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_VALUEdisables 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:
java.lang.IllegalArgumentException- if bytes is non-positive- Since:
- 1.17.0
-
getServerConfiguration
@NonNull public GrpcSslConfiguration getServerConfiguration()
The SSL configuration.- Returns:
- The SSL configuration
-
setAwaitTermination
public void setAwaitTermination(java.time.Duration awaitTermination)
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
public java.time.Duration 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
@Inject public void setServerConfiguration(GrpcSslConfiguration sslConfiguration)
Sets the SSL configuration.- Parameters:
sslConfiguration- The server configuration
-
-