Class IdempotencyConfig
java.lang.Object
io.github.ravocode.avoonce.core.config.IdempotencyConfig
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 Summary
ConstructorsConstructorDescriptionDefault constructor with configurable environment variable overrides.IdempotencyConfig(long ttl, TimeUnit unit) Constructs anIdempotencyConfigwith the given TTL and default lock timeout (2 minutes).IdempotencyConfig(long ttl, TimeUnit unit, long lockTimeout, TimeUnit lockTimeoutUnit) Constructs anIdempotencyConfigwith explicit TTL and lock-timeout settings. -
Method Summary
-
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
Constructs anIdempotencyConfigwith the given TTL and default lock timeout (2 minutes).- Parameters:
ttl- the cache duration value.unit- the time unit for the TTL.
-
IdempotencyConfig
Constructs anIdempotencyConfigwith explicit TTL and lock-timeout settings.- Parameters:
ttl- the cache duration valueunit- the time unit for the TTLlockTimeout- the maximum duration a STARTED lock is validlockTimeoutUnit- the time unit forlockTimeout
-
-
Method Details
-
getTtl
public long getTtl()Returns the idempotency response cache TTL value.- Returns:
- the TTL duration as a long.
-
getUnit
-
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
-