Class GrpcServerConfiguration

java.lang.Object
io.micronaut.grpc.server.GrpcServerConfiguration

@ConfigurationProperties("grpc.server") public class GrpcServerConfiguration extends Object
Configuration for the GRPC server.
Since:
1.0
Author:
graemerocher, Iván López
  • Field Details

  • 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 environment
      serverHost - The server host
      serverPort - The server port
      executorService - The IO executor service
      resourceResolver - 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

      public Optional<String> getServerHost()
      The server host.
      Returns:
      The server host
    • getServerPort

      public int getServerPort()
      The server port.
      Returns:
      The server port
    • getInstanceId

      @NonNull public @NonNull String getInstanceId()
      The instance id.
      Returns:
      The instance id
    • setInstanceId

      public void setInstanceId(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:
      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

      @NonNull public @NonNull GrpcSslConfiguration getServerConfiguration()
      The SSL configuration.
      Returns:
      The SSL configuration
    • setAwaitTermination

      public void setAwaitTermination(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 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