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

original IdempotencyKey

IdempotencyKey(string)

Initializes a new instance of the IdempotencyKey record.

public IdempotencyKey(string value)

Parameters

value string

The 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

int

Properties

EqualityContract

protected override Type EqualityContract { get; }

Property Value

Type

Methods

Equals(IdempotencyKey?)

public virtual bool Equals(IdempotencyKey? other)

Parameters

other IdempotencyKey

Returns

bool

Equals(ConceptAs<string>?)

public override sealed bool Equals(ConceptAs<string>? other)

Parameters

other ConceptAs<string>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

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

index int

The zero-based position of the event in the batch.

Returns

IdempotencyKey

A derived key of 64 characters.

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected override bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

Operators

operator ==(IdempotencyKey?, IdempotencyKey?)

public static bool operator ==(IdempotencyKey? left, IdempotencyKey? right)

Parameters

left IdempotencyKey
right IdempotencyKey

Returns

bool

operator !=(IdempotencyKey?, IdempotencyKey?)

public static bool operator !=(IdempotencyKey? left, IdempotencyKey? right)

Parameters

left IdempotencyKey
right IdempotencyKey

Returns

bool