Class IdempotencyKeyStorage
- Namespace
- FlowOrchestrator.Core.Storage
- Assembly
- FlowOrchestrator.Core.dll
The one normalisation every built-in store applies to a caller-supplied idempotency key before it is stored or looked up, so SQL Server, PostgreSQL and the in-memory store deduplicate identically.
public static class IdempotencyKeyStorage
- Inheritance
-
IdempotencyKeyStorage
- Inherited Members
Remarks
The key is the raw value of the client's Idempotency-Key header and nothing upstream caps its
length, while the SQL Server / PostgreSQL key columns hold MaxStoredLength characters.
A key that would not fit is stored as DigestPrefix + the lower-case hex SHA-256 of its
normalised UTF-8 bytes (71 characters): equal keys still map to the same row, and no schema change is
needed. Custom stores should call Normalize(string) too, so a key deduplicates the same way
whichever backend a deployment moves to.
Fields
DigestPrefix
Prefix marking a stored key as the digest of a longer one.
public const string DigestPrefix = "sha256:"
Field Value
MaxStoredLength
Length of the idempotency-key columns of the built-in SQL Server and PostgreSQL schemas.
public const int MaxStoredLength = 256
Field Value
Methods
Normalize(string)
Returns the deduplication form of idempotencyKey: trimmed, lower-cased with the
invariant culture, and replaced by its digest when that is longer than MaxStoredLength.
public static string Normalize(string idempotencyKey)
Parameters
idempotencyKeystringThe caller-supplied key.
Returns
- string
A string of at most MaxStoredLength characters.
Remarks
Trimming and lower-casing match what every built-in store already did before the length cap was added, so keys of 256 characters or fewer are stored exactly as before.
TakenOverCancelReason(Guid)
Returns the cancel reason a store records on a run whose idempotency reservation was taken over by TryTakeOverStaleIdempotencyKeyAsync(Guid, string, string, Guid, Guid, TimeSpan).
public static string TakenOverCancelReason(Guid newRunId)
Parameters
newRunIdGuidThe run that took the key over.
Returns
- string
A reason naming
newRunId, so the dashboard links the dead run to its replacement.
ToStorageForm(string?)
Returns idempotencyKey unchanged when it fits MaxStoredLength, and its
Normalize(string)d digest form otherwise.
public static string? ToStorageForm(string? idempotencyKey)
Parameters
Returns
- string
A value that fits the run-control record's idempotency-key column.
Remarks
For the informational copy on IdempotencyKey: a short key keeps the caller's spelling there, a long one is recorded as the same digest the dedup table holds.