Interface ResilientValue<T>
- Type Parameters:
T- type of the loaded value
- All Superinterfaces:
Supplier<T>
A value loaded on first use using a timeout and retry protected by a circuit breaker.
Each loader invocation is guarded by the timeout, the retry repeats timed attempts, and the circuit breaker wraps
the complete retry batch.
The timeout must execute on the current thread so a retry cannot overlap a timed-out loader that is still
unwinding. The timeout interrupts the loader at its deadline; interruption-aware or independently bounded I/O is
required for prompt termination.
A successfully loaded value is cached permanently. Failed loads may be tried again according to the configured
circuit breaker. Concurrent callers wait for the active load attempt and share its result.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classException indicating that a source may become available later. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ResilientValue<T> create(ResilientValueConfig<T> config) Create a resilient value using the provided configuration.booleanloaded()Whether the value has already been loaded successfully.
-
Method Details
-
create
Create a resilient value using the provided configuration. Fault tolerance state belongs to the configured handlers; callers should supply dedicated instances when state must not be shared with other operations.- Type Parameters:
T- type of the loaded value- Parameters:
config- resilient value configuration- Returns:
- a new resilient value
- Throws:
IllegalArgumentException- if the timeout is not positive, exceeds the retry overall timeout, or does not execute on the current thread
-
loaded
boolean loaded()Whether the value has already been loaded successfully.- Returns:
trueif the value is loaded
-