Class GrpcServerProperties

java.lang.Object
net.devh.boot.grpc.server.config.GrpcServerProperties

@ConfigurationProperties("grpc.server") public class GrpcServerProperties extends Object
The properties for the gRPC server that will be started as part of the application.
Since:
5/17/16
  • Field Details

    • ANY_IP_ADDRESS

      public static final String ANY_IP_ADDRESS
      A constant that defines, that the server should listen to any IPv4 and IPv6 address.
      See Also:
    • ANY_IPv4_ADDRESS

      public static final String ANY_IPv4_ADDRESS
      A constant that defines, that the server should listen to any IPv4 address.
      See Also:
    • ANY_IPv6_ADDRESS

      public static final String ANY_IPv6_ADDRESS
      A constant that defines, that the server should listen to any IPv6 address.
      See Also:
  • Constructor Details

    • GrpcServerProperties

      public GrpcServerProperties()
  • Method Details

    • getPort

      public int getPort()
      Gets the port the server should listen on. Defaults to 9090. If set to 0 a random available port will be selected and used.
      Returns:
      The server port to listen to.
      See Also:
    • setMaxInboundMessageSize

      public void setMaxInboundMessageSize(DataSize maxInboundMessageSize)
      Sets the maximum message size allowed to be received by the server. If not set (null) then it will default to gRPC's default. If set to -1 then it will use the highest possible limit (not recommended).
      Parameters:
      maxInboundMessageSize - The new maximum size allowed for incoming messages. -1 for max possible. Null to use the gRPC's default.
      See Also:
    • setMaxInboundMetadataSize

      public void setMaxInboundMetadataSize(DataSize maxInboundMetadataSize)
      Sets the maximum metadata size allowed to be received by the server. If not set (null) then it will default to gRPC's default. If set to -1 then it will use the highest possible limit (not recommended).
      Parameters:
      maxInboundMetadataSize - The new maximum size allowed for incoming metadata. -1 for max possible. Null to use the gRPC's default.
      See Also:
    • getAddress

      public String getAddress()
      Bind address for the server. Defaults to "*". Alternatively you can restrict this to "0.0.0.0" or "::". Or restrict it to exactly one IP address. On unix systems it is also possible to prefix it with unix: to use domain socket addresses/paths (Additional dependencies may be required).
      Returns:
      The address the server should bind to.
    • getInProcessName

      public String getInProcessName()
      The name of the in-process server. If not set, then the in process server won't be started.
      Returns:
      The name of the in-process server or null if isn't configured.
    • getShutdownGracePeriod

      public Duration getShutdownGracePeriod()
      The time to wait for the server to gracefully shutdown (completing all requests after the server started to shutdown). If set to a negative value, the server waits forever. If set to 0 the server will force shutdown immediately. Defaults to 30s.
      Returns:
      The time to wait for a graceful shutdown.
    • isEnableKeepAlive

      public boolean isEnableKeepAlive()
      Setting to enable keepAlive. Default to false.
      Returns:
      True, if keep alive should be enabled. False otherwise.
    • getKeepAliveTime

      public Duration getKeepAliveTime()
      The default delay before we send a keepAlives. Defaults to 2h. Default unit SECONDS.
      Returns:
      The default delay before sending keepAlives.
      See Also:
    • getKeepAliveTimeout

      public Duration getKeepAliveTimeout()
      The default timeout for a keepAlives ping request. Defaults to 20s. Default unit SECONDS.
      Returns:
      The default timeout for a keepAlives ping request.
      See Also:
    • getPermitKeepAliveTime

      public Duration getPermitKeepAliveTime()
      Specify the most aggressive keep-alive time clients are permitted to configure. Defaults to 5min. Default unit SECONDS.
      Returns:
      The most aggressive keep-alive time clients are permitted to configure.
      See Also:
      • NettyServerBuilder.permitKeepAliveTime(long, TimeUnit)
    • isPermitKeepAliveWithoutCalls

      public boolean isPermitKeepAliveWithoutCalls()
      Whether clients are allowed to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection. Defaults to false.
      Returns:
      True, if clients are allowed to send keep-alive requests without calls. False otherwise.
      See Also:
      • NettyServerBuilder.permitKeepAliveWithoutCalls(boolean)
    • getMaxConnectionIdle

      public Duration getMaxConnectionIdle()
      Specify a max connection idle time. Defaults to disabled. Default unit SECONDS.
      Returns:
      The max connection idle time.
      See Also:
      • NettyServerBuilder.maxConnectionIdle(long, TimeUnit)
    • getMaxConnectionAge

      public Duration getMaxConnectionAge()
      Specify a max connection age. Defaults to disabled. Default unit SECONDS.
      Returns:
      The max connection age.
      See Also:
      • NettyServerBuilder.maxConnectionAge(long, TimeUnit)
    • getMaxConnectionAgeGrace

      public Duration getMaxConnectionAgeGrace()
      Specify a grace time for the graceful max connection age termination. Defaults to disabled. Default unit SECONDS.
      Returns:
      The max connection age grace time.
      See Also:
      • NettyServerBuilder.maxConnectionAgeGrace(long, TimeUnit)
    • getMaxInboundMessageSize

      public DataSize getMaxInboundMessageSize()
      The maximum message size allowed to be received by the server. If not set (null) then gRPC's default should be used.
      Returns:
      The maximum message size allowed.
    • getMaxInboundMetadataSize

      public DataSize getMaxInboundMetadataSize()
      The maximum size of metadata allowed to be received. If not set (null) then gRPC's default should be used.
      Returns:
      The maximum metadata size allowed.
    • isHealthServiceEnabled

      public boolean isHealthServiceEnabled()
      Whether gRPC health service is enabled or not. Defaults to true.
      Returns:
      True, if the health service is enabled. False otherwise.
    • isReflectionServiceEnabled

      public boolean isReflectionServiceEnabled()
      Whether proto reflection service is enabled or not. Defaults to true.
      Returns:
      True, if the reflection service is enabled. False otherwise.
    • getSecurity

      public GrpcServerProperties.Security getSecurity()
      Security options for transport security. Defaults to disabled. We strongly recommend to enable this though.
      Returns:
      The security options for transport security.
    • setAddress

      public void setAddress(String address)
      Bind address for the server. Defaults to "*". Alternatively you can restrict this to "0.0.0.0" or "::". Or restrict it to exactly one IP address. On unix systems it is also possible to prefix it with unix: to use domain socket addresses/paths (Additional dependencies may be required).
      Parameters:
      address - The address to bind to.
    • setPort

      public void setPort(int port)
      Server port to listen on. Defaults to 9090. If set to 0 a random available port will be selected and used. Use -1 to disable the inter-process server (for example if you only want to use the in-process server).
      Parameters:
      port - The port the server should listen on.
    • setInProcessName

      public void setInProcessName(String inProcessName)
      The name of the in-process server. If not set, then the in process server won't be started.
      Parameters:
      inProcessName - The name of the in-process server.
    • setShutdownGracePeriod

      public void setShutdownGracePeriod(Duration shutdownGracePeriod)
      The time to wait for the server to gracefully shutdown (completing all requests after the server started to shutdown). If set to a negative value, the server waits forever. If set to 0 the server will force shutdown immediately. Defaults to 30s.
      Parameters:
      shutdownGracePeriod - The time to wait for a graceful shutdown.
    • setEnableKeepAlive

      public void setEnableKeepAlive(boolean enableKeepAlive)
      Setting to enable keepAlive. Default to false.
      Parameters:
      enableKeepAlive - Whether keep alive should be enabled.
    • setKeepAliveTime

      public void setKeepAliveTime(Duration keepAliveTime)
      The default delay before we send a keepAlives. Defaults to 2h. Default unit SECONDS.
      Parameters:
      keepAliveTime - The new default delay before sending keepAlives.
      See Also:
    • setKeepAliveTimeout

      public void setKeepAliveTimeout(Duration keepAliveTimeout)
      The default timeout for a keepAlives ping request. Defaults to 20s. Default unit SECONDS.
      Parameters:
      keepAliveTimeout - Sets the default timeout for a keepAlives ping request.
      See Also:
    • setPermitKeepAliveTime

      public void setPermitKeepAliveTime(Duration permitKeepAliveTime)
      Specify the most aggressive keep-alive time clients are permitted to configure. Defaults to 5min. Default unit SECONDS.
      Parameters:
      permitKeepAliveTime - The most aggressive keep-alive time clients are permitted to configure.
      See Also:
      • NettyServerBuilder.permitKeepAliveTime(long, TimeUnit)
    • setPermitKeepAliveWithoutCalls

      public void setPermitKeepAliveWithoutCalls(boolean permitKeepAliveWithoutCalls)
      Whether clients are allowed to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection. Defaults to false.
      Parameters:
      permitKeepAliveWithoutCalls - Whether to allow clients to send keep-alive requests without calls.
      See Also:
      • NettyServerBuilder.permitKeepAliveWithoutCalls(boolean)
    • setMaxConnectionIdle

      public void setMaxConnectionIdle(Duration maxConnectionIdle)
      Specify a max connection idle time. Defaults to disabled. Default unit SECONDS.
      Parameters:
      maxConnectionIdle - The max connection idle time.
      See Also:
      • NettyServerBuilder.maxConnectionIdle(long, TimeUnit)
    • setMaxConnectionAge

      public void setMaxConnectionAge(Duration maxConnectionAge)
      Specify a max connection age. Defaults to disabled. Default unit SECONDS.
      Parameters:
      maxConnectionAge - The max connection age.
      See Also:
      • NettyServerBuilder.maxConnectionAge(long, TimeUnit)
    • setMaxConnectionAgeGrace

      public void setMaxConnectionAgeGrace(Duration maxConnectionAgeGrace)
      Specify a grace time for the graceful max connection age termination. Defaults to disabled. Default unit SECONDS.
      Parameters:
      maxConnectionAgeGrace - The max connection age grace time.
      See Also:
      • NettyServerBuilder.maxConnectionAgeGrace(long, TimeUnit)
    • setHealthServiceEnabled

      public void setHealthServiceEnabled(boolean healthServiceEnabled)
      Whether gRPC health service is enabled or not. Defaults to true.
      Parameters:
      healthServiceEnabled - Whether gRPC health service is enabled.
    • setReflectionServiceEnabled

      public void setReflectionServiceEnabled(boolean reflectionServiceEnabled)
      Whether proto reflection service is enabled or not. Defaults to true.
      Parameters:
      reflectionServiceEnabled - Whether gRPC reflection service is enabled.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object