Record Class ResilienceConfig

java.lang.Object
java.lang.Record
com.tnsai.resilience.ResilienceConfig
Record Components:
retry - retry policy, or null for no retry
timeoutMs - per-attempt timeout in ms; <= 0 means no timeout

public record ResilienceConfig(RetryPolicy retry, int timeoutMs) extends Record
Programmatic resilience policy for a builder-built Role — the builder-path counterpart of the @Resilience annotation (TNS-567). Without it, a role created via RoleBuilder could only get a resilience policy by subclassing; now it attaches one with RoleBuilder.resilience(...) and ActionExecutor applies it through the same ResilienceExecutor path as the annotation.

Scope — enforced subset only

This models the @Resilience features that are actually applied at runtime today: retry (RetryPolicy) and timeout. The annotation's circuitBreaker, rateLimit, bulkhead and fallback are scaffold that ActionExecutor.applyResilience does not yet honor (Phase 2 of TNS-565), so they are deliberately not modeled here — a builder field for an unenforced feature would be a silent no-op. They will be added once the runtime wires them.
Since:
0.12.0 (TNS-567)
  • Field Details

  • Constructor Details

    • ResilienceConfig

      public ResilienceConfig(RetryPolicy retry, int timeoutMs)
      Creates an instance of a ResilienceConfig record class.
      Parameters:
      retry - the value for the retry record component
      timeoutMs - the value for the timeoutMs record component
  • Method Details

    • isEmpty

      public boolean isEmpty()
      True when neither retry nor timeout is configured.
    • from

      public static ResilienceConfig from(Resilience annotation)
      Adapts the enforced subset of a @Resilience annotation (retry + timeout). The annotation's not-yet-wired fields (circuitBreaker, rateLimit, bulkhead, fallback) are ignored — see the class scope note.
    • builder

      public static ResilienceConfig.Builder builder()
    • 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 '=='.
      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.
    • retry

      public RetryPolicy retry()
      Returns the value of the retry record component.
      Returns:
      the value of the retry record component
    • timeoutMs

      public int timeoutMs()
      Returns the value of the timeoutMs record component.
      Returns:
      the value of the timeoutMs record component