Class DefaultExpiryPolicy<T>
java.lang.Object
com.societegenerale.failover.core.expiry.DefaultExpiryPolicy<T>
- Type Parameters:
T- the payload type whose expiry this policy governs
- All Implemented Interfaces:
ExpiryPolicy<T>
Default
ExpiryPolicy that computes expiry by adding the annotation-configured duration
to the current clock time, and checks expiry against the current clock.- Author:
- Anand Manissery
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeExpiry(Failover failover) Computes the expiry instant for a payload stored under the given failover.booleanisExpired(Failover failover, ReferentialPayload<T> referentialPayload) Returnstrueif the stored payload has expired.
-
Constructor Details
-
DefaultExpiryPolicy
public DefaultExpiryPolicy()
-
-
Method Details
-
computeExpiry
Description copied from interface:ExpiryPolicyComputes the expiry instant for a payload stored under the given failover.Implementation contract: Must return a non-null instant in the future relative to "now" — a freshly stored payload must not already be expired. The result is stored as the payload's
expireOn. Verify your implementation withExpiryPolicyContractVerifier.- Specified by:
computeExpiryin interfaceExpiryPolicy<T>- Parameters:
failover- annotation metadata containing the configured expiry duration and unit- Returns:
- the absolute instant after which the stored payload should be considered expired
-
isExpired
Description copied from interface:ExpiryPolicyReturnstrueif the stored payload has expired.Implementation contract: Must decide expiry from the payload's
expireOnrelative to the current time (consistent withExpiryPolicy.computeExpiry(com.societegenerale.failover.annotations.Failover)): an entry stored a moment ago is not expired; an entry whoseexpireOnis in the past is. Must be side-effect-free.- Specified by:
isExpiredin interfaceExpiryPolicy<T>- Parameters:
failover- annotation metadata for the failover pointreferentialPayload- the stored payload to check- Returns:
trueif the payload's expiry time is in the past
-