Class IdempotencyKey
- Namespace
- Cratis.Chronicle.EventSequences
- Assembly
- Cratis.Chronicle.dll
Represents a caller-chosen key that makes an append idempotent: appending again with the same key never writes the event twice.
public record IdempotencyKey : ConceptAs<string>, IComparable<ConceptAs<string>>, IComparable<string>, IComparable, IEquatable<ConceptAs<string>>, IEquatable<IdempotencyKey>
- Inheritance
-
IdempotencyKey
- Implements
- Inherited Members
- Extension Methods
Remarks
There is deliberately no implicit conversion from string; a key is always created explicitly. Never put personal data in a key - it is stored with the event.
Constructors
IdempotencyKey(IdempotencyKey)
protected IdempotencyKey(IdempotencyKey original)
Parameters
originalIdempotencyKey
IdempotencyKey(string)
Initializes a new instance of the IdempotencyKey record.
public IdempotencyKey(string value)
Parameters
valuestringThe key, 1 to MaximumLength characters.
Exceptions
- IdempotencyKeyNotValid
The key is empty or longer than MaximumLength.
Fields
MaximumLength
The maximum number of characters in a key.
public const int MaximumLength = 512
Field Value
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Methods
Equals(IdempotencyKey?)
public virtual bool Equals(IdempotencyKey? other)
Parameters
otherIdempotencyKey
Returns
Equals(ConceptAs<string>?)
public override sealed bool Equals(ConceptAs<string>? other)
Parameters
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
ForIndex(int)
Derives the key for one event of a batch, so a batch keyed once is keyed per event.
public IdempotencyKey ForIndex(int index)
Parameters
indexintThe zero-based position of the event in the batch.
Returns
- IdempotencyKey
A derived key of 64 characters.
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected override bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
Operators
operator ==(IdempotencyKey?, IdempotencyKey?)
public static bool operator ==(IdempotencyKey? left, IdempotencyKey? right)
Parameters
leftIdempotencyKeyrightIdempotencyKey
Returns
operator !=(IdempotencyKey?, IdempotencyKey?)
public static bool operator !=(IdempotencyKey? left, IdempotencyKey? right)
Parameters
leftIdempotencyKeyrightIdempotencyKey