Class IdempotencyConfig

java.lang.Object
io.github.ravocode.avoonce.core.config.IdempotencyConfig

public class IdempotencyConfig extends Object
Immutable configuration for the AvoOnce idempotency layer.

Controls the response cache TTL and the maximum lock-hold duration before an in-progress request is considered stale and its lock can be reclaimed.

In non-Spring environments this class is constructed directly. In Spring Boot, it is wired automatically from IdempotencyProperties via auto-configuration.

  • Constructor Details

    • IdempotencyConfig

      public IdempotencyConfig()
      Default constructor with configurable environment variable overrides.

      Reads the following environment variables (falling back to safe defaults):

      • AVOONCE_IDEMPOTENCY_TTL — TTL value (default: 1)
      • AVOONCE_IDEMPOTENCY_TIMEUNIT — TTL unit (default: HOURS)
      • AVOONCE_IDEMPOTENCY_LOCK_TIMEOUT — lock timeout value (default: 2)
      • AVOONCE_IDEMPOTENCY_LOCK_TIMEUNIT — lock timeout unit (default: MINUTES)
    • IdempotencyConfig

      public IdempotencyConfig(long ttl, TimeUnit unit)
      Constructs an IdempotencyConfig with the given TTL and default lock timeout (2 minutes).
      Parameters:
      ttl - the cache duration value.
      unit - the time unit for the TTL.
    • IdempotencyConfig

      public IdempotencyConfig(long ttl, TimeUnit unit, long lockTimeout, TimeUnit lockTimeoutUnit)
      Constructs an IdempotencyConfig with explicit TTL and lock-timeout settings.
      Parameters:
      ttl - the cache duration value
      unit - the time unit for the TTL
      lockTimeout - the maximum duration a STARTED lock is valid
      lockTimeoutUnit - the time unit for lockTimeout
  • Method Details

    • getTtl

      public long getTtl()
      Returns the idempotency response cache TTL value.
      Returns:
      the TTL duration as a long.
    • getUnit

      public TimeUnit getUnit()
      Returns the time unit for the TTL value.
      Returns:
      the TimeUnit for the TTL.
    • getLockTimeout

      public long getLockTimeout()
      Returns the maximum lock-hold duration before a STARTED record is considered stale.
      Returns:
      the lock timeout duration as a long.
    • getLockTimeoutUnit

      public TimeUnit getLockTimeoutUnit()
      Returns the time unit for the lock timeout value.
      Returns:
      the TimeUnit for the lock timeout.