Class IdempotencyRecord
java.lang.Object
io.github.ravocode.avoonce.core.domain.IdempotencyRecord
Immutable value object representing a single idempotency record stored in the repository.
A record captures the full lifecycle of an idempotent request:
from the initial lock acquisition (IdempotencyStatus.STARTED),
through successful completion (IdempotencyStatus.COMPLETED),
or failure (IdempotencyStatus.FAILED).
Repository implementations use this record to enforce exactly-once processing guarantees and replay cached responses on retry.
-
Constructor Summary
ConstructorsConstructorDescriptionIdempotencyRecord(String idempotencyKey, IdempotencyStatus status, IdempotencyResponse response, Long expiresAt) Constructs anIdempotencyRecordwithout a request hash (hash validation disabled).IdempotencyRecord(String idempotencyKey, IdempotencyStatus status, IdempotencyResponse response, Long expiresAt, String requestHash) Constructs anIdempotencyRecordwith full fields including a request hash. -
Method Summary
Modifier and TypeMethodDescriptionReturns the epoch-millisecond timestamp at which the STARTED lock expires.Returns the unique idempotency key.Returns the SHA-256 hash of the original request body used for payload mismatch detection.Returns the cached HTTP response for replay, ornullif the request has not completed successfully.Returns the current lifecycle status of this record.
-
Constructor Details
-
IdempotencyRecord
public IdempotencyRecord(String idempotencyKey, IdempotencyStatus status, IdempotencyResponse response, Long expiresAt) Constructs anIdempotencyRecordwithout a request hash (hash validation disabled).- Parameters:
idempotencyKey- the unique idempotency key.status- the current lifecycle status.response- the cached response, ornullif not yet completed.expiresAt- the epoch-millisecond expiry timestamp, ornullfor COMPLETED records.
-
IdempotencyRecord
public IdempotencyRecord(String idempotencyKey, IdempotencyStatus status, IdempotencyResponse response, Long expiresAt, String requestHash) Constructs anIdempotencyRecordwith full fields including a request hash.- Parameters:
idempotencyKey- the unique idempotency key.status- the current lifecycle status.response- the cached response, ornullif not yet completed.expiresAt- the epoch-millisecond expiry timestamp, ornullfor COMPLETED records.requestHash- the SHA-256 hash of the original request body; may benullto skip validation.
-
-
Method Details
-
getIdempotencyKey
Returns the unique idempotency key.- Returns:
- the idempotency key string.
-
getStatus
Returns the current lifecycle status of this record.- Returns:
- the
IdempotencyStatus.
-
getResponse
Returns the cached HTTP response for replay, ornullif the request has not completed successfully.- Returns:
- the
IdempotencyResponse, ornull.
-
getExpiresAt
Returns the epoch-millisecond timestamp at which the STARTED lock expires.- Returns:
- the expiry timestamp in milliseconds, or
nullfor COMPLETED records.
-
getRequestHash
Returns the SHA-256 hash of the original request body used for payload mismatch detection.- Returns:
- the hex-encoded SHA-256 hash, or
nullif hash validation is disabled.
-