Class GrpcServerConfiguration


  • @ConfigurationProperties("grpc.server")
    public class GrpcServerConfiguration
    extends java.lang.Object
    Configuration for the GRPC server.
    Since:
    1.0
    • 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.
    • Field Detail

      • HEALTH_ENABLED

        @Deprecated
        public static final java.lang.String HEALTH_ENABLED
        Deprecated.
        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 environment
        serverHost - The server host
        serverPort - The server port
        executorService - 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 environment
        serverHost - The server host
        serverPort - The server port
        executorService - The IO executor service
        resourceResolver - 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_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:
        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