Record Class GrpcCircuitBreakerConfiguration

java.lang.Object
java.lang.Record
io.micronaut.grpc.client.circuitbreaker.GrpcCircuitBreakerConfiguration
Record Components:
channelName - The channel name
enabled - Whether the circuit breaker is enabled for the channel
failureThreshold - The number of consecutive failed calls that opens the circuit
resetTimeout - How long the circuit stays open before a trial call is let through
failureStatusCodes - The status codes that count as failures

public record GrpcCircuitBreakerConfiguration(String channelName, boolean enabled, int failureThreshold, Duration resetTimeout, Set<io.grpc.Status.Code> failureStatusCodes) extends Record
Circuit breaker settings of a gRPC channel, read from grpc.channels.<name>.circuit-breaker.*.
Since:
5.3.0
  • Field Details

    • PREFIX

      public static final String PREFIX
      The property suffix under a channel's prefix.
      See Also:
    • DEFAULT_FAILURE_THRESHOLD

      public static final int DEFAULT_FAILURE_THRESHOLD
      The default number of consecutive failures that opens the circuit.
      See Also:
    • DEFAULT_RESET_TIMEOUT

      public static final Duration DEFAULT_RESET_TIMEOUT
      The default time the circuit stays open.
    • DEFAULT_FAILURE_STATUS_CODES

      public static final Set<io.grpc.Status.Code> DEFAULT_FAILURE_STATUS_CODES
      The status codes that count as failures by default: those that indicate the server is unreachable or overloaded, rather than an application error.
  • Constructor Details

    • GrpcCircuitBreakerConfiguration

      public GrpcCircuitBreakerConfiguration(String channelName, boolean enabled, int failureThreshold, Duration resetTimeout, Set<io.grpc.Status.Code> failureStatusCodes)
      Validates the configuration.
  • Method Details

    • of

      public static GrpcCircuitBreakerConfiguration of(io.micronaut.context.env.Environment environment, String channelName)
      Reads the circuit breaker settings of a channel from the environment.
      Parameters:
      environment - The environment
      channelName - The channel name
      Returns:
      The configuration
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • channelName

      public String channelName()
      Returns the value of the channelName record component.
      Returns:
      the value of the channelName record component
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • failureThreshold

      public int failureThreshold()
      Returns the value of the failureThreshold record component.
      Returns:
      the value of the failureThreshold record component
    • resetTimeout

      public Duration resetTimeout()
      Returns the value of the resetTimeout record component.
      Returns:
      the value of the resetTimeout record component
    • failureStatusCodes

      public Set<io.grpc.Status.Code> failureStatusCodes()
      Returns the value of the failureStatusCodes record component.
      Returns:
      the value of the failureStatusCodes record component