record
CausationId
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct CausationId : IComparable<CausationId>, IComparable, ISpanFormattable, ISpanParsable<CausationId>, IUtf8SpanParsable<CausationId>
Implements: IComparable, IComparable<CausationId>, ISpanFormattable, ISpanParsable<CausationId>, IUtf8SpanParsable<CausationId>
Represents a strongly typed identifier for the direct trigger or parent message that caused an action.
Members (26)
constructorCausationId
public CausationId(string value)
Initializes a new instance of the `CausationId` struct with the specified string value.
- value: string
- The causation identifier string.
methodCompareTo
public int CompareTo(CausationId other)
Inherits documentation from base type or interface.
- other: CausationId
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static CausationId From(string value)
Creates a `CausationId` from the specified string.
- value: string
- The causation identifier string.
Returns: A new `CausationId` instance.
methodFromGuid
public static CausationId FromGuid(Guid value)
Creates a `CausationId` from the specified `Guid`.
- value: Guid
- The unique identifier GUID.
Returns: A new `CausationId` instance.
methodFromString
public static CausationId FromString(string value)
Creates a `CausationId` from the specified string.
- value: string
- The causation identifier string.
Returns: A new `CausationId` instance.
methodNewId
public static CausationId NewId()
Creates a new `CausationId` from a time-ordered UUIDv7.
Returns: A new `CausationId` instance.
methodParse
public static CausationId Parse(ReadOnlySpan<byte> utf8Text)
Parses a span of UTF-8 bytes into a `CausationId`.
- utf8Text: ReadOnlySpan<byte>
- The span of UTF-8 bytes to parse.
Returns: The parsed `CausationId`.
methodParse
public static CausationId Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
methodParse
public static CausationId Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `CausationId`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `CausationId`.
methodParse
public static CausationId Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static CausationId Parse(string s)
Parses a string into a `CausationId`.
- s: string
- The string to parse.
Returns: The parsed `CausationId`.
methodParse
public static CausationId Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out CausationId result)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
- result: out CausationId
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out CausationId result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out CausationId
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out CausationId result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out CausationId
methodexplicit operator CausationId
public static explicit operator CausationId(string value)
Converts a string to a `CausationId` instance.
- value: string
- The causation identifier string.
methodimplicit operator string
public static implicit operator string(CausationId id)
Converts a `CausationId` to its underlying string representation.
- id: CausationId
- The causation identifier to convert.
methodoperator <
public static bool operator <(CausationId left, CausationId right)
Determines whether one `CausationId` instance is less than another.
- left: CausationId
- The first causation identifier to compare.
- right: CausationId
- The second causation identifier to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(CausationId left, CausationId right)
Determines whether one `CausationId` instance is less than or equal to another.
- left: CausationId
- The first causation identifier to compare.
- right: CausationId
- The second causation identifier to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(CausationId left, CausationId right)
Determines whether one `CausationId` instance is greater than another.
- left: CausationId
- The first causation identifier to compare.
- right: CausationId
- The second causation identifier to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(CausationId left, CausationId right)
Determines whether one `CausationId` instance is greater than or equal to another.
- left: CausationId
- The first causation identifier to compare.
- right: CausationId
- The second causation identifier to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyValue
public string Value { get; }
Gets the string value of the causation identifier.
record
CompensationAction
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record CompensationAction
Represents an executable compensation instruction that semantically undoes or mitigates a completed step.
Members (6)
constructorCompensationAction
public CompensationAction(string stepName, object payload)
Initializes a new instance of the `CompensationAction` record with the specified step name and payload.
- stepName: string
- The unique logical name of the step to compensate.
- payload: object
- The payload containing parameters required to execute the compensation.
methodCreate<TPayload>
public static CompensationAction Create<TPayload>(string stepName, TPayload payload) where TPayload : notnull
Creates a new `CompensationAction` instance with the specified step name and payload.
- stepName: string
- The unique logical name of the step to compensate.
- payload: TPayload
- The compensation action payload.
Returns: A new `CompensationAction` instance.
methodExtractPayload<T>
public T ExtractPayload<T>()
Extracts the compensation payload cast to the specified type.
Returns: The payload cast to `T`.
methodTryExtractPayload<T>
public bool TryExtractPayload<T>(out T? payload)
Attempts to extract the compensation payload as the specified type.
- payload: out T?
- When this method returns, contains the typed payload if successful; otherwise, the default value for `T`.
Returns: `true` if the payload is of type `T`; otherwise, `false`.
propertyPayload
public object Payload { get; init; }
Gets the payload containing parameters required to execute the compensation.
propertyStepName
public string StepName { get; init; }
Gets the unique logical name of the step to compensate.
class
CompensationFailedException
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class CompensationFailedException : ProcessException
Inherits: ProcessException
Represents errors caused by a failure during saga compensation execution.
Members (5)
constructorCompensationFailedException
public CompensationFailedException()
Initializes a new instance of the `CompensationFailedException` class.
constructorCompensationFailedException
public CompensationFailedException(ProcessId processId, string stepName, string reason, Exception? innerException = null)
Initializes a new instance of the `CompensationFailedException` class with the step name and failure details.
- processId: ProcessId
- The unique process identifier.
- stepName: string
- The name of the step that failed to compensate.
- reason: string
- The explanation of the failure.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
constructorCompensationFailedException
public CompensationFailedException(string message)
Initializes a new instance of the `CompensationFailedException` class with a specified error message.
- message: string
- The message that describes the error.
constructorCompensationFailedException
public CompensationFailedException(string message, Exception? innerException)
Initializes a new instance of the `CompensationFailedException` class with a specified error message and inner exception.
- message: string
- The error message that explains the reason for the exception.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
propertyStepName
public string StepName { get; }
Gets the name of the step that failed to compensate.
record
CompensationStep
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record CompensationStep
Represents a recorded milestone of a completed saga step, storing the payload required for reverse compensation.
Members (11)
constructorCompensationStep
public CompensationStep(string stepName, object payload, DateTimeOffset recordedAt, string? failureReason = null, DateTimeOffset? failedAt = null)
Initializes a new instance of the `CompensationStep` record with the specified step name, payload, and timestamp.
- stepName: string
- The unique logical name of the step.
- payload: object
- The payload recorded during forward execution.
- recordedAt: DateTimeOffset
- The UTC timestamp when the step was recorded.
- failureReason: string?
- The optional failure reason explanation.
- failedAt: DateTimeOffset?
- The optional UTC timestamp when the step failed.
methodCreate<TPayload>
public static CompensationStep Create<TPayload>(string stepName, TPayload payload, DateTimeOffset recordedAt) where TPayload : notnull
Creates a new `CompensationStep` instance with the specified step name, payload, and timestamp.
- stepName: string
- The unique logical name of the step.
- payload: TPayload
- The recorded step payload.
- recordedAt: DateTimeOffset
- The UTC timestamp when the step was recorded.
Returns: A new `CompensationStep` instance.
methodExtractPayload<T>
public T ExtractPayload<T>()
Extracts the recorded payload cast to the specified type.
Returns: The payload cast to `T`.
methodTryExtractPayload<T>
public bool TryExtractPayload<T>(out T? payload)
Attempts to extract the recorded payload as the specified type.
- payload: out T?
- When this method returns, contains the typed payload if successful; otherwise, the default value for `T`.
Returns: `true` if the payload is of type `T`; otherwise, `false`.
methodWithFailure
public CompensationStep WithFailure(string failureReason, DateTimeOffset failedAt)
Creates a copy of this compensation step annotated with failure details.
- failureReason: string
- The failure reason explanation.
- failedAt: DateTimeOffset
- The UTC timestamp when the failure occurred.
Returns: A new `CompensationStep` record with failure information recorded.
propertyFailedAt
public DateTimeOffset? FailedAt { get; init; }
Gets the UTC timestamp when the failure occurred, if any.
propertyFailureReason
public string? FailureReason { get; init; }
Gets the failure reason explanation if this compensation step failed.
propertyHasFailed
public bool HasFailed { get; }
Gets a value indicating whether this compensation step has failed.
propertyPayload
public object Payload { get; init; }
Gets the payload recorded during forward execution.
propertyRecordedAt
public DateTimeOffset RecordedAt { get; init; }
Gets the UTC timestamp when the step was recorded.
propertyStepName
public string StepName { get; init; }
Gets the unique logical step name.
class
CompensationStepJsonSerializer
Assembly: EricksonLopez.Processes.Abstractionspublic static class CompensationStepJsonSerializer
Provides Native AOT and trimming-safe JSON serialization and deserialization for `CompensationStep` collections.
Members (2)
methodDeserialize
public static IReadOnlyList<CompensationStep> Deserialize(string? json)
Deserializes a JSON array string into a read-only list of `CompensationStep` instances.
- json: string?
- The JSON array string to deserialize.
Returns: A read-only list of `CompensationStep` instances.
methodSerialize
public static string Serialize(IReadOnlyList<CompensationStep>? steps)
Serializes a list of `CompensationStep` instances to a JSON array string.
- steps: IReadOnlyList<CompensationStep>?
- The compensation steps to serialize.
Returns: A JSON array string representing the recorded compensation steps.
record
CompositeCorrelationKey
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct CompositeCorrelationKey : IEquatable<CompositeCorrelationKey>
Implements: IEquatable<CompositeCorrelationKey>
Represents a composite, deterministic correlation key constructed from multiple business identifiers.
Members (7)
constructorCompositeCorrelationKey
public CompositeCorrelationKey(params string[] parts)
Initializes a new instance of the `CompositeCorrelationKey` struct with the specified key parts.
- parts: params string[]
- The key parts to combine.
methodFrom<T1, T2, T3, T4>
public static CompositeCorrelationKey From<T1, T2, T3, T4>(T1 part1, T2 part2, T3 part3, T4 part4) where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull
Creates a new composite correlation key from four strongly typed parts.
- part1: T1
- The first key part.
- part2: T2
- The second key part.
- part3: T3
- The third key part.
- part4: T4
- The fourth key part.
Returns: A new `CompositeCorrelationKey` instance.
methodFrom<T1, T2, T3>
public static CompositeCorrelationKey From<T1, T2, T3>(T1 part1, T2 part2, T3 part3) where T1 : notnull where T2 : notnull where T3 : notnull
Creates a new composite correlation key from three strongly typed parts.
- part1: T1
- The first key part.
- part2: T2
- The second key part.
- part3: T3
- The third key part.
Returns: A new `CompositeCorrelationKey` instance.
methodFrom<T1, T2>
public static CompositeCorrelationKey From<T1, T2>(T1 part1, T2 part2) where T1 : notnull where T2 : notnull
Creates a new composite correlation key from two strongly typed parts.
- part1: T1
- The first key part.
- part2: T2
- The second key part.
Returns: A new `CompositeCorrelationKey` instance.
methodToCorrelationId
public CorrelationId ToCorrelationId()
Converts this composite correlation key into a deterministic `CorrelationId`.
Returns: A deterministic `CorrelationId` generated via SHA-256 hashing.
methodToString
public override string ToString()
Inherits documentation from base type or interface.
propertyValue
public string Value { get; }
Gets the normalized combined key string value.
class
ConcurrencyConflictException
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class ConcurrencyConflictException : ProcessException
Inherits: ProcessException
Represents errors caused by an optimistic concurrency conflict during process persistence.
Members (5)
constructorConcurrencyConflictException
public ConcurrencyConflictException()
Initializes a new instance of the `ConcurrencyConflictException` class.
constructorConcurrencyConflictException
public ConcurrencyConflictException(ProcessId processId, Revision expectedRevision)
Initializes a new instance of the `ConcurrencyConflictException` class with the specified process identifier and expected revision.
- processId: ProcessId
- The unique process identifier.
- expectedRevision: Revision
- The expected revision token.
constructorConcurrencyConflictException
public ConcurrencyConflictException(string message)
Initializes a new instance of the `ConcurrencyConflictException` class with a specified error message.
- message: string
- The message that describes the error.
constructorConcurrencyConflictException
public ConcurrencyConflictException(string message, Exception? innerException)
Initializes a new instance of the `ConcurrencyConflictException` class with a specified error message and inner exception.
- message: string
- The error message that explains the reason for the exception.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
propertyExpectedRevision
public Revision ExpectedRevision { get; }
Gets the revision expected by the storage persistence operation.
record
CorrelationId
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct CorrelationId : IComparable<CorrelationId>, IComparable, ISpanFormattable, ISpanParsable<CorrelationId>, IUtf8SpanParsable<CorrelationId>
Implements: IComparable, IComparable<CorrelationId>, ISpanFormattable, ISpanParsable<CorrelationId>, IUtf8SpanParsable<CorrelationId>
Represents a strongly typed identifier for the overarching business transaction or conversation thread.
Members (27)
constructorCorrelationId
public CorrelationId(string value)
Initializes a new instance of the `CorrelationId` struct with the specified string value.
- value: string
- The correlation identifier string.
methodCompareTo
public int CompareTo(CorrelationId other)
Inherits documentation from base type or interface.
- other: CorrelationId
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static CorrelationId From(Guid value)
Creates a `CorrelationId` from the specified `Guid`.
- value: Guid
- The unique identifier GUID.
Returns: A new `CorrelationId` instance.
methodFrom
public static CorrelationId From(string value)
Creates a `CorrelationId` from the specified string.
- value: string
- The correlation identifier string.
Returns: A new `CorrelationId` instance.
methodFromGuid
public static CorrelationId FromGuid(Guid value)
Creates a `CorrelationId` from the specified `Guid`.
- value: Guid
- The unique identifier GUID.
Returns: A new `CorrelationId` instance.
methodFromString
public static CorrelationId FromString(string value)
Creates a `CorrelationId` from the specified string.
- value: string
- The correlation identifier string.
Returns: A new `CorrelationId` instance.
methodNewId
public static CorrelationId NewId()
Creates a new `CorrelationId` from a time-ordered UUIDv7.
Returns: A new `CorrelationId` instance.
methodParse
public static CorrelationId Parse(ReadOnlySpan<byte> utf8Text)
Parses a span of UTF-8 bytes into a `CorrelationId`.
- utf8Text: ReadOnlySpan<byte>
- The span of UTF-8 bytes to parse.
Returns: The parsed `CorrelationId`.
methodParse
public static CorrelationId Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
methodParse
public static CorrelationId Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `CorrelationId`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `CorrelationId`.
methodParse
public static CorrelationId Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static CorrelationId Parse(string s)
Parses a string into a `CorrelationId`.
- s: string
- The string to parse.
Returns: The parsed `CorrelationId`.
methodParse
public static CorrelationId Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out CorrelationId result)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
- result: out CorrelationId
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out CorrelationId result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out CorrelationId
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out CorrelationId result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out CorrelationId
methodexplicit operator CorrelationId
public static explicit operator CorrelationId(string value)
Converts a string to a `CorrelationId` instance.
- value: string
- The correlation identifier string.
methodimplicit operator string
public static implicit operator string(CorrelationId id)
Converts a `CorrelationId` to its underlying string representation.
- id: CorrelationId
- The correlation identifier to convert.
methodoperator <
public static bool operator <(CorrelationId left, CorrelationId right)
Determines whether one `CorrelationId` instance is less than another.
- left: CorrelationId
- The first correlation identifier to compare.
- right: CorrelationId
- The second correlation identifier to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(CorrelationId left, CorrelationId right)
Determines whether one `CorrelationId` instance is less than or equal to another.
- left: CorrelationId
- The first correlation identifier to compare.
- right: CorrelationId
- The second correlation identifier to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(CorrelationId left, CorrelationId right)
Determines whether one `CorrelationId` instance is greater than another.
- left: CorrelationId
- The first correlation identifier to compare.
- right: CorrelationId
- The second correlation identifier to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(CorrelationId left, CorrelationId right)
Determines whether one `CorrelationId` instance is greater than or equal to another.
- left: CorrelationId
- The first correlation identifier to compare.
- right: CorrelationId
- The second correlation identifier to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyValue
public string Value { get; }
Gets the string value of the correlation identifier.
interface
ICompensationHandler<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface ICompensationHandler<TState> where TState : notnull
Defines a contract for executing compensation logic for a previously completed saga step.
Members (1)
methodCompensateAsync
ValueTask<ProcessTransitionResult<TState>> CompensateAsync(TState state, CompensationAction action, ProcessContext context)
Executes compensation logic for the specified compensation action and payload.
- state: TState
- The current saga state.
- action: CompensationAction
- The compensation action containing the step name and payload.
- context: ProcessContext
- The process execution context.
Returns: A value task representing the asynchronous operation. The task result contains the resulting process state transition.
interface
IProcessCoordinator<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessCoordinator<TState> where TState : notnull
Defines the application-facing contract for coordinating stateful process transitions, saga compensations, and durable persistence.
Members (6)
methodCompensateAsync<TSaga>
ValueTask<ProcessExecutionResult<TState>> CompensateAsync<TSaga>(ProcessId processId, IReadOnlyList<CompensationStep> recordedSteps, TSaga saga, CancellationToken cancellationToken = default) where TSaga : IProcess<TState>, ICompensationHandler<TState>
Executes reverse-order compensation steps for a saga using optimistic concurrency control.
- processId: ProcessId
- The unique process identifier of the saga to compensate.
- recordedSteps: IReadOnlyList<CompensationStep>
- The list of steps recorded during forward execution.
- saga: TSaga
- The saga instance providing compensation logic.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the `ProcessExecutionResult<TState>`.
methodCompensateAsync<TSaga>
ValueTask<ProcessExecutionResult<TState>> CompensateAsync<TSaga>(ProcessId processId, TSaga saga, CancellationToken cancellationToken = default) where TSaga : IProcess<TState>, ICompensationHandler<TState>
Executes reverse-order compensation steps for a saga using optimistic concurrency control, automatically reading recorded compensation steps from the persisted process instance.
- processId: ProcessId
- The unique process identifier of the saga to compensate.
- saga: TSaga
- The saga instance providing compensation logic.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the `ProcessExecutionResult<TState>`.
methodExecuteAsync<TEvent>
ValueTask<ProcessExecutionResult<TState>> ExecuteAsync<TEvent>(IProcessHandler<TState, TEvent> handler, IProcessCorrelation<TEvent> correlation, TEvent eventMessage, Func<TEvent, TState>? initialStateFactory = null, bool canInitiate = false, CancellationToken cancellationToken = default)
Executes a process handler against the targeted process instance with optimistic concurrency retries.
- handler: IProcessHandler<TState, TEvent>
- The typed process handler to invoke.
- correlation: IProcessCorrelation<TEvent>
- The correlation extractor used to obtain identifiers from the event.
- eventMessage: TEvent
- The incoming event instance to handle.
- initialStateFactory: Func<TEvent, TState>?
- The factory function to initialize state when a new instance is created.
- canInitiate: bool
- A value indicating whether this event is allowed to initiate a new process instance.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the `ProcessExecutionResult<TState>`.
methodInitiateAsync<TEvent>
ValueTask<ProcessExecutionResult<TState>> InitiateAsync<TEvent>(IProcessHandler<TState, TEvent> handler, IProcessCorrelation<TEvent> correlation, TEvent eventMessage, Func<TEvent, TState> initialStateFactory, CancellationToken cancellationToken = default)
Initiates a new process instance using a required initial state factory and executes the initial message transition.
- handler: IProcessHandler<TState, TEvent>
- The typed process handler to invoke.
- correlation: IProcessCorrelation<TEvent>
- The correlation extractor used to obtain identifiers from the event.
- eventMessage: TEvent
- The incoming event instance to handle.
- initialStateFactory: Func<TEvent, TState>
- The required factory function to initialize state when a new instance is created.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the `ProcessExecutionResult<TState>`.
methodResumeAsync<TEvent>
ValueTask<ProcessExecutionResult<TState>> ResumeAsync<TEvent>(IProcessHandler<TState, TEvent> handler, IProcessCorrelation<TEvent> correlation, TEvent eventMessage, CancellationToken cancellationToken = default)
Resumes an existing persisted process instance and executes the specified continuation message transition. Throws `ProcessNotFoundException` if the process instance does not exist in storage.
- handler: IProcessHandler<TState, TEvent>
- The typed process handler to invoke.
- correlation: IProcessCorrelation<TEvent>
- The correlation extractor used to obtain identifiers from the event.
- eventMessage: TEvent
- The incoming event instance to handle.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the `ProcessExecutionResult<TState>`.
methodStartAsync<TEvent>
ValueTask<ProcessExecutionResult<TState>> StartAsync<TEvent>(IProcessHandler<TState, TEvent> handler, IProcessCorrelation<TEvent> correlation, TEvent eventMessage, Func<TEvent, TState> initialStateFactory, CancellationToken cancellationToken = default)
Initiates a new process instance using a required initial state factory and executes the initial message transition.
- handler: IProcessHandler<TState, TEvent>
- The typed process handler to invoke.
- correlation: IProcessCorrelation<TEvent>
- The correlation extractor used to obtain identifiers from the event.
- eventMessage: TEvent
- The incoming event instance to handle.
- initialStateFactory: Func<TEvent, TState>
- The required factory function to initialize state when a new instance is created.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the `ProcessExecutionResult<TState>`.
interface
IProcessCorrelation<TEvent>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessCorrelation<TEvent>
Defines a strongly typed correlation extractor mapping incoming events to process identifiers.
Members (3)
methodExtractCausationId
CausationId? ExtractCausationId(TEvent event)
Extracts the optional causation identifier from the specified event.
- event: TEvent
- The incoming event instance.
Returns: The `CausationId` if present; otherwise, `null`.
methodExtractCorrelationId
CorrelationId ExtractCorrelationId(TEvent event)
Extracts the business correlation identifier from the specified event.
- event: TEvent
- The incoming event instance.
Returns: The target `CorrelationId`.
methodExtractProcessId
ProcessId ExtractProcessId(TEvent event)
Extracts the process instance identifier from the specified event.
- event: TEvent
- The incoming event instance.
Returns: The target `ProcessId`.
interface
IProcessHandler<TState, TEvent>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessHandler<TState, TEvent> : IProcess<TState> where TState : notnull
Implements: IProcess<TState>
Defines a strongly typed handler contract for reacting to an incoming domain event within a process manager.
Members (1)
methodHandleAsync
ValueTask<ProcessTransitionResult<TState>> HandleAsync(TState state, TEvent eventMessage, ProcessContext context)
Handles the incoming event message, producing the resulting updated state and emitted effects.
- state: TState
- The current process state.
- eventMessage: TEvent
- The incoming event payload.
- context: ProcessContext
- The process execution context.
Returns: A value task representing the asynchronous operation. The task result contains the state transition result.
interface
IProcessState
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessState
Defines a marker interface representing the domain state schema of a process instance.
Members (0)
This type declares 0 public members (e.g. marker interface or empty enum/record).
interface
IProcessStateMigrator<TFrom, TTo>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessStateMigrator<TFrom, TTo> where TFrom : notnull where TTo : notnull
Defines a contract for migrating process state from a source schema to a target schema version.
Members (3)
methodMigrate
TTo Migrate(TFrom sourceState)
Migrates the specified source state to the target schema.
- sourceState: TFrom
- The source state instance to migrate.
Returns: The migrated state instance conforming to the target schema.
propertyFromVersion
ProcessVersion FromVersion { get; }
Gets the source schema version.
propertyToVersion
ProcessVersion ToVersion { get; }
Gets the target schema version.
interface
IProcessStateSerializer<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessStateSerializer<TState> where TState : notnull
Defines a contract for serializing and deserializing process domain state instances.
Members (2)
methodDeserialize
TState Deserialize(ReadOnlySpan<byte> data)
Deserializes the byte span into a process state instance.
- data: ReadOnlySpan<byte>
- The serialized byte span to deserialize.
Returns: The deserialized process state instance.
methodSerialize
byte[] Serialize(TState state)
Serializes the specified state instance into a byte array.
- state: TState
- The process state instance to serialize.
Returns: The serialized byte array.
interface
IProcessStore<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcessStore<TState> where TState : notnull
Defines the persistence contract for loading, querying, and saving process instances in durable storage.
Members (5)
methodBeginConnectionScopeAsync
ValueTask<IAsyncDisposable?> BeginConnectionScopeAsync(CancellationToken cancellationToken = default)
Begins an optional connection-leasing scope across an execution or retry cycle to avoid connection pool churn.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains an `IAsyncDisposable` scope, or `null` if connection scoping is not used by the store.
methodExistsAsync
ValueTask<bool> ExistsAsync(ProcessId id, CancellationToken cancellationToken = default)
Determines whether a process instance with the specified identifier exists in storage.
- id: ProcessId
- The unique process identifier.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains `true` if the instance exists; otherwise, `false`.
methodGetByCorrelationIdAsync
ValueTask<ProcessInstance<TState>?> GetByCorrelationIdAsync(CorrelationId correlationId, CancellationToken cancellationToken = default)
Retrieves a process instance by its business correlation identifier.
- correlationId: CorrelationId
- The business correlation identifier.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the matching `ProcessInstance<TState>`, or `null` if not found.
methodGetByIdAsync
ValueTask<ProcessInstance<TState>?> GetByIdAsync(ProcessId id, CancellationToken cancellationToken = default)
Retrieves a process instance by its unique identifier.
- id: ProcessId
- The unique process identifier.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the persisted `ProcessInstance<TState>`, or `null` if not found.
methodSaveAsync
ValueTask<ProcessSaveResult> SaveAsync(ProcessInstance<TState> instance, CancellationToken cancellationToken = default)
Persists a new or updated process instance using optimistic concurrency control.
- instance: ProcessInstance<TState>
- The process instance to save.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains a `ProcessSaveResult` indicating the outcome.
interface
IProcess<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface IProcess<TState> where TState : notnull
Defines the core contract for a Process Manager definition.
Members (2)
propertyType
ProcessType Type { get; }
Gets the unique logical process type identity.
propertyVersion
ProcessVersion Version { get; }
Gets the schema or definition version of this process.
interface
ISagaSnapshotRepository<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface ISagaSnapshotRepository<TState> where TState : notnull
Defines the snapshot storage contract for capturing and restoring process state checkpoints.
Members (2)
methodGetLatestSnapshotAsync
ValueTask<(Revision Revision, TState State)?> GetLatestSnapshotAsync(ProcessId processId, CancellationToken cancellationToken = default)
Retrieves the most recent snapshot checkpoint for the given process identifier.
- processId: ProcessId
- The unique process identifier.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation. The task result contains the latest snapshot tuple of revision and state, or `null` if no snapshot exists.
methodSaveSnapshotAsync
ValueTask SaveSnapshotAsync(ProcessId processId, Revision revision, TState state, CancellationToken cancellationToken = default)
Saves a snapshot checkpoint of the process state.
- processId: ProcessId
- The unique process identifier.
- revision: Revision
- The revision at which the snapshot was captured.
- state: TState
- The state instance to snapshot.
- cancellationToken: CancellationToken
- A token that can be used to cancel the asynchronous operation.
Returns: A value task representing the asynchronous operation.
interface
ISaga<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic interface ISaga<TState> : IProcess<TState> where TState : notnull
Implements: IProcess<TState>
Defines a saga orchestration contract with support for explicit step compensation.
Members (0)
This type declares 0 public members (e.g. marker interface or empty enum/record).
class
InvalidProcessTransitionException
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class InvalidProcessTransitionException : ProcessException
Inherits: ProcessException
Represents errors caused by attempting an invalid or forbidden process state transition.
Members (6)
constructorInvalidProcessTransitionException
public InvalidProcessTransitionException()
Initializes a new instance of the `InvalidProcessTransitionException` class.
constructorInvalidProcessTransitionException
public InvalidProcessTransitionException(ProcessId processId, ProcessStatus currentStatus, ProcessStatus attemptedStatus, string reason)
Initializes a new instance of the `InvalidProcessTransitionException` class with transition status details.
- processId: ProcessId
- The unique process identifier.
- currentStatus: ProcessStatus
- The current status of the process.
- attemptedStatus: ProcessStatus
- The attempted target status.
- reason: string
- The explanation for why the transition is invalid.
constructorInvalidProcessTransitionException
public InvalidProcessTransitionException(string message)
Initializes a new instance of the `InvalidProcessTransitionException` class with a specified error message.
- message: string
- The message that describes the error.
constructorInvalidProcessTransitionException
public InvalidProcessTransitionException(string message, Exception? innerException)
Initializes a new instance of the `InvalidProcessTransitionException` class with a specified error message and inner exception.
- message: string
- The error message that explains the reason for the exception.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
propertyAttemptedStatus
public ProcessStatus AttemptedStatus { get; }
Gets the target lifecycle status that was attempted.
propertyCurrentStatus
public ProcessStatus CurrentStatus { get; }
Gets the current lifecycle status of the process instance.
record
MessageId
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct MessageId : IComparable<MessageId>, IComparable, ISpanFormattable, ISpanParsable<MessageId>, IUtf8SpanParsable<MessageId>
Implements: IComparable, IComparable<MessageId>, ISpanFormattable, ISpanParsable<MessageId>, IUtf8SpanParsable<MessageId>
Represents a strongly typed unique identifier for a specific message, command, or event instance.
Members (26)
constructorMessageId
public MessageId(string value)
Initializes a new instance of the `MessageId` struct with the specified string value.
- value: string
- The message identifier string.
methodCompareTo
public int CompareTo(MessageId other)
Inherits documentation from base type or interface.
- other: MessageId
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static MessageId From(string value)
Creates a `MessageId` from the specified string.
- value: string
- The message identifier string.
Returns: A new `MessageId` instance.
methodFromGuid
public static MessageId FromGuid(Guid value)
Creates a `MessageId` from the specified `Guid`.
- value: Guid
- The unique identifier GUID.
Returns: A new `MessageId` instance.
methodFromString
public static MessageId FromString(string value)
Creates a `MessageId` from the specified string.
- value: string
- The message identifier string.
Returns: A new `MessageId` instance.
methodNewId
public static MessageId NewId()
Creates a new `MessageId` from a time-ordered UUIDv7.
Returns: A new `MessageId` instance.
methodParse
public static MessageId Parse(ReadOnlySpan<byte> utf8Text)
Parses a span of UTF-8 bytes into a `MessageId`.
- utf8Text: ReadOnlySpan<byte>
- The span of UTF-8 bytes to parse.
Returns: The parsed `MessageId`.
methodParse
public static MessageId Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
methodParse
public static MessageId Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `MessageId`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `MessageId`.
methodParse
public static MessageId Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static MessageId Parse(string s)
Parses a string into a `MessageId`.
- s: string
- The string to parse.
Returns: The parsed `MessageId`.
methodParse
public static MessageId Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out MessageId result)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
- result: out MessageId
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out MessageId result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out MessageId
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out MessageId result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out MessageId
methodexplicit operator MessageId
public static explicit operator MessageId(string value)
Converts a string to a `MessageId` instance.
- value: string
- The message identifier string.
methodimplicit operator string
public static implicit operator string(MessageId id)
Converts a `MessageId` to its underlying string representation.
- id: MessageId
- The message identifier to convert.
methodoperator <
public static bool operator <(MessageId left, MessageId right)
Determines whether one `MessageId` instance is less than another.
- left: MessageId
- The first message identifier to compare.
- right: MessageId
- The second message identifier to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(MessageId left, MessageId right)
Determines whether one `MessageId` instance is less than or equal to another.
- left: MessageId
- The first message identifier to compare.
- right: MessageId
- The second message identifier to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(MessageId left, MessageId right)
Determines whether one `MessageId` instance is greater than another.
- left: MessageId
- The first message identifier to compare.
- right: MessageId
- The second message identifier to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(MessageId left, MessageId right)
Determines whether one `MessageId` instance is greater than or equal to another.
- left: MessageId
- The first message identifier to compare.
- right: MessageId
- The second message identifier to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyValue
public string Value { get; }
Gets the string value of the message identifier.
record
PersistedCompensationStepRecord
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record PersistedCompensationStepRecord(string StepName, DateTimeOffset RecordedAt, string? ContextPayload, string? FailureReason, DateTimeOffset? FailedAt)
Represents the wire-level persistence record for a single `CompensationStep`.
Members (6)
constructorPersistedCompensationStepRecord
public PersistedCompensationStepRecord(string StepName, DateTimeOffset RecordedAt, string? ContextPayload, string? FailureReason = null, DateTimeOffset? FailedAt = null)
Initializes a new instance of PersistedCompensationStepRecord.
- StepName: string
- The logical name of the compensation step.
- RecordedAt: DateTimeOffset
- The UTC timestamp when the step was recorded.
- ContextPayload: string?
- The optional contextual metadata payload.
- FailureReason: string?
- The optional failure reason if the compensation step failed.
- FailedAt: DateTimeOffset?
- The optional UTC timestamp when the compensation step failed.
propertyContextPayload
public string? ContextPayload { get; init; }
The optional contextual metadata payload.
propertyFailedAt
public DateTimeOffset? FailedAt { get; init; }
The optional UTC timestamp when the compensation step failed.
propertyFailureReason
public string? FailureReason { get; init; }
The optional failure reason if the compensation step failed.
propertyRecordedAt
public DateTimeOffset RecordedAt { get; init; }
The UTC timestamp when the step was recorded.
propertyStepName
public string StepName { get; init; }
The logical name of the compensation step.
class
ProcessContext
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class ProcessContext
Provides contextual execution metadata and services to a process handler or saga step.
Members (10)
constructorProcessContext
public ProcessContext(ProcessId processId, CorrelationId correlationId, CausationId causationId, MessageId messageId, DateTimeOffset now, TimeProvider? timeProvider = null, IReadOnlyDictionary<string, object?>? items = null, CancellationToken cancellationToken = default)
Initializes a new instance of the `ProcessContext` class with the specified metadata and services.
- processId: ProcessId
- The unique process identifier.
- correlationId: CorrelationId
- The business correlation identifier.
- causationId: CausationId
- The causation identifier of the trigger message.
- messageId: MessageId
- The unique message identifier.
- now: DateTimeOffset
- The UTC timestamp when execution began.
- timeProvider: TimeProvider?
- The optional time provider instance, or `null` to use `TimeProvider.System`.
- items: IReadOnlyDictionary<string, object?>?
- The optional contextual items dictionary, or `null`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the execution step.
methodCreate
public static ProcessContext Create(ProcessId processId, CorrelationId correlationId, CausationId? causationId = null, MessageId? messageId = null, TimeProvider? timeProvider = null, IReadOnlyDictionary<string, object?>? items = null, CancellationToken cancellationToken = default)
Creates a new `ProcessContext` with defaults for optional message identifiers and timestamps.
- processId: ProcessId
- The unique process identifier.
- correlationId: CorrelationId
- The business correlation identifier.
- causationId: CausationId?
- The optional causation identifier, or `null` to derive from the message identifier.
- messageId: MessageId?
- The optional message identifier, or `null` to generate a new time-ordered identifier.
- timeProvider: TimeProvider?
- The optional time provider instance, or `null` to use `TimeProvider.System`.
- items: IReadOnlyDictionary<string, object?>?
- The optional contextual items dictionary, or `null`.
- cancellationToken: CancellationToken
- A token that can be used to cancel the execution step.
Returns: A new `ProcessContext` instance.
propertyCancellationToken
public CancellationToken CancellationToken { get; }
Gets the cancellation token for the current execution step.
propertyCausationId
public CausationId CausationId { get; }
Gets the causation identifier of the trigger message.
propertyCorrelationId
public CorrelationId CorrelationId { get; }
Gets the overarching business correlation identifier.
propertyItems
public IReadOnlyDictionary<string, object?> Items { get; }
Gets contextual key-value items passed into this execution.
propertyMessageId
public MessageId MessageId { get; }
Gets the unique identifier of the incoming message.
propertyNow
public DateTimeOffset Now { get; }
Gets the deterministic UTC timestamp when execution began.
propertyProcessId
public ProcessId ProcessId { get; }
Gets the unique identifier of the process instance.
propertyTimeProvider
public TimeProvider TimeProvider { get; }
Gets the time provider for timestamp and delay calculations.
class
ProcessDefinitionAttribute
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class ProcessDefinitionAttribute : Attribute
Inherits: Attribute
Specifies that a class is a process manager definition discovered for compile-time registration.
Members (3)
constructorProcessDefinitionAttribute
public ProcessDefinitionAttribute(string processType, int version = 1)
Initializes a new instance of the `ProcessDefinitionAttribute` class with the specified process type and version.
- processType: string
- The logical process type identifier.
- version: int
- The schema or definition version number.
propertyProcessType
public string ProcessType { get; }
Gets the unique logical process type identifier.
propertyVersion
public int Version { get; }
Gets the schema or definition version number.
record
ProcessEffect
Assembly: EricksonLopez.Processes.Abstractionspublic abstract record ProcessEffect
Represents an outbound side-effect intent produced by a process state transition.
Members (5)
methodCreateCommand<T>
public static Command CreateCommand<T>(T payload, string? commandType = null) where T : notnull
Creates a new `Command` effect with the specified payload and command type.
- payload: T
- The command payload instance.
- commandType: string?
- The optional logical command type name.
Returns: A new `Command` effect instance.
methodCreateCompensation
public static Compensation CreateCompensation(CompensationAction action)
Creates a new `Compensation` effect with the specified action.
- action: CompensationAction
- The compensation action details.
Returns: A new `Compensation` effect instance.
methodCreateCompensation<T>
public static Compensation CreateCompensation<T>(string stepName, T payload) where T : notnull
Creates a new `Compensation` effect with the specified step name and payload.
- stepName: string
- The unique logical name of the step to compensate.
- payload: T
- The compensation action payload.
Returns: A new `Compensation` effect instance.
methodCreateEvent<T>
public static Event CreateEvent<T>(T payload, string? eventType = null) where T : notnull
Creates a new `Event` effect with the specified payload and event type.
- payload: T
- The event payload instance.
- eventType: string?
- The optional logical event type name.
Returns: A new `Event` effect instance.
methodCreateTimeout<T>
public static ScheduleTimeout CreateTimeout<T>(TimeSpan delay, T trigger, string? triggerType = null) where T : notnull
Creates a new `ScheduleTimeout` effect with the specified delay, trigger, and trigger type.
- delay: TimeSpan
- The duration before the timeout expires.
- trigger: T
- The trigger payload to deliver when the timeout expires.
- triggerType: string?
- The optional logical trigger type name.
Returns: A new `ScheduleTimeout` effect instance.
record
ProcessEffect.Command
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record Command(object CommandPayload, string? CommandType) : ProcessEffect
Inherits: ProcessEffect
Represents an intent to issue an asynchronous command.
Members (5)
constructorCommand
public Command(object CommandPayload, string? CommandType = null)
Initializes a new instance of Command.
- CommandPayload: object
- The command payload object.
- CommandType: string?
- Optional logical type name of the command.
methodGetPayload<T>
public T GetPayload<T>()
Gets the command payload cast to the specified type.
Returns: The cast command instance.
methodTryGetPayload<T>
public bool TryGetPayload<T>(out T? payload)
Attempts to get the command payload as the specified type.
- payload: out T?
- When this method returns, contains the command payload if of type `T`; otherwise, the default value for `T`.
Returns: `true` if the payload is of type `T`; otherwise, `false`.
propertyCommandPayload
public object CommandPayload { get; init; }
Gets the command payload object.
propertyCommandType
public string? CommandType { get; init; }
Optional logical type name of the command.
record
ProcessEffect.Compensation
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record Compensation(CompensationAction Action) : ProcessEffect
Inherits: ProcessEffect
Represents an intent to execute a compensating action.
Members (2)
constructorCompensation
public Compensation(CompensationAction Action)
Initializes a new instance of Compensation.
- Action: CompensationAction
- The compensation action details.
propertyAction
public CompensationAction Action { get; init; }
Gets the compensation action details.
record
ProcessEffect.Event
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record Event(object EventPayload, string? EventType) : ProcessEffect
Inherits: ProcessEffect
Represents an intent to publish an outbound domain or integration event.
Members (5)
constructorEvent
public Event(object EventPayload, string? EventType = null)
Initializes a new instance of Event.
- EventPayload: object
- The event payload object.
- EventType: string?
- Optional logical type name of the event.
methodGetPayload<T>
public T GetPayload<T>()
Gets the event payload cast to the specified type.
Returns: The cast event instance.
methodTryGetPayload<T>
public bool TryGetPayload<T>(out T? payload)
Attempts to get the event payload as the specified type.
- payload: out T?
- When this method returns, contains the event payload if of type `T`; otherwise, the default value for `T`.
Returns: `true` if the payload is of type `T`; otherwise, `false`.
propertyEventPayload
public object EventPayload { get; init; }
Gets the event payload object.
propertyEventType
public string? EventType { get; init; }
Optional logical type name of the event.
record
ProcessEffect.ScheduleTimeout
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record ScheduleTimeout(TimeSpan Delay, object TimeoutTrigger, string? TriggerType) : ProcessEffect
Inherits: ProcessEffect
Represents an intent to schedule a timeout or wake-up trigger after a duration.
Members (6)
constructorScheduleTimeout
public ScheduleTimeout(TimeSpan Delay, object TimeoutTrigger, string? TriggerType = null)
Initializes a new instance of ScheduleTimeout.
- Delay: TimeSpan
- The duration to wait before triggering the timeout.
- TimeoutTrigger: object
- The trigger payload to deliver when the timeout expires.
- TriggerType: string?
- Optional logical type of the trigger.
methodGetTrigger<T>
public T GetTrigger<T>()
Gets the timeout trigger payload cast to the specified type.
Returns: The cast trigger instance.
methodTryGetTrigger<T>
public bool TryGetTrigger<T>(out T? trigger)
Attempts to get the timeout trigger payload as the specified type.
- trigger: out T?
- When this method returns, contains the trigger payload if of type `T`; otherwise, the default value for `T`.
Returns: `true` if the trigger is of type `T`; otherwise, `false`.
propertyDelay
public TimeSpan Delay { get; init; }
The duration to wait before triggering the timeout.
propertyTimeoutTrigger
public object TimeoutTrigger { get; init; }
Gets the timeout trigger payload object.
propertyTriggerType
public string? TriggerType { get; init; }
Optional logical type of the trigger.
class
ProcessException
Assembly: EricksonLopez.Processes.Abstractionspublic class ProcessException : Exception
Inherits: Exception
Represents errors that occur during process manager or saga execution.
Members (5)
constructorProcessException
public ProcessException()
Initializes a new instance of the `ProcessException` class.
constructorProcessException
public ProcessException(string message)
Initializes a new instance of the `ProcessException` class with a specified error message.
- message: string
- The message that describes the error.
constructorProcessException
public ProcessException(string message, Exception? innerException)
Initializes a new instance of the `ProcessException` class with a specified error message and inner exception.
- message: string
- The error message that explains the reason for the exception.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
constructorProcessException
public ProcessException(string message, ProcessId? processId, Exception? innerException = null)
Initializes a new instance of the `ProcessException` class with a specified error message, process identifier, and inner exception.
- message: string
- The error message that explains the reason for the exception.
- processId: ProcessId?
- The process identifier associated with the exception, or `null`.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
propertyProcessId
public ProcessId? ProcessId { get; }
Gets the process identifier associated with the exception, if available.
record
ProcessExecutionResult<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record ProcessExecutionResult<TState> where TState : notnull
Represents the final result of coordinating and persisting a process step.
Members (10)
constructorProcessExecutionResult
public ProcessExecutionResult(ProcessInstance<TState> instance, IReadOnlyList<ProcessEffect> effects, ProcessSaveResult saveResult, IReadOnlyList<CompensationStep>? recordedCompensations = null, string? failureReason = null)
Initializes a new instance of the `ProcessExecutionResult<TState>` record with the instance, effects, and save result.
- instance: ProcessInstance<TState>
- The persisted process instance after the transition.
- effects: IReadOnlyList<ProcessEffect>
- The list of side-effect intents emitted by the transition.
- saveResult: ProcessSaveResult
- The persistence outcome resulting from saving the instance.
- recordedCompensations: IReadOnlyList<CompensationStep>?
- The optional list of compensations recorded during execution.
- failureReason: string?
- The optional failure reason when the process transitions to `ProcessStatus.Failed`.
propertyEffects
public IReadOnlyList<ProcessEffect> Effects { get; init; }
Gets the list of side-effect intents emitted by the transition.
propertyFailureReason
public string? FailureReason { get; init; }
Gets the optional failure reason if the transition or compensation resulted in a failure.
propertyInstance
public ProcessInstance<TState> Instance { get; init; }
Gets the persisted process instance after the transition.
propertyIsBusinessFailure
public bool IsBusinessFailure { get; }
Gets a value indicating whether the process transitioned to `ProcessStatus.Failed` and that failure state was durably persisted.
propertyIsConcurrencyConflict
public bool IsConcurrencyConflict { get; }
Gets a value indicating whether the execution failed to persist due to an optimistic concurrency conflict.
propertyIsPersisted
public bool IsPersisted { get; }
Gets a value indicating whether the state was durably persisted without a storage concurrency conflict, regardless of whether the resulting business status is `ProcessStatus.Failed`.
propertyIsSuccess
public bool IsSuccess { get; }
Gets a value indicating whether both storage persistence succeeded AND the domain process did not transition to `ProcessStatus.Failed`.
propertyRecordedCompensations
public IReadOnlyList<CompensationStep> RecordedCompensations { get; init; }
Gets the list of compensations recorded by this process instance.
propertySaveResult
public ProcessSaveResult SaveResult { get; init; }
Gets the persistence outcome resulting from saving the instance.
class
ProcessHandlerAttribute
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class ProcessHandlerAttribute : Attribute
Inherits: Attribute
Specifies that a method handles incoming events within a process manager or saga.
Members (2)
constructorProcessHandlerAttribute
public ProcessHandlerAttribute(bool canInitiate = false)
Initializes a new instance of the `ProcessHandlerAttribute` class with the initiation capability indicator.
- canInitiate: bool
- A value indicating whether the handled event can initiate a new process instance.
propertyCanInitiate
public bool CanInitiate { get; }
Gets a value indicating whether the handled event can initiate a new process instance when none exists.
record
ProcessId
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct ProcessId : IComparable<ProcessId>, IComparable, ISpanFormattable, ISpanParsable<ProcessId>, IUtf8SpanParsable<ProcessId>
Implements: IComparable, IComparable<ProcessId>, ISpanFormattable, ISpanParsable<ProcessId>, IUtf8SpanParsable<ProcessId>
Represents a strongly typed, immutable identifier for a process instance.
Members (27)
constructorProcessId
public ProcessId(Guid value)
Initializes a new instance of the `ProcessId` struct with the specified `Guid`.
- value: Guid
- The underlying unique identifier.
methodCompareTo
public int CompareTo(ProcessId other)
Inherits documentation from base type or interface.
- other: ProcessId
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static ProcessId From(Guid value)
Creates a `ProcessId` from an existing `Guid`.
- value: Guid
- The underlying unique identifier GUID.
Returns: A new `ProcessId` instance.
methodFromGuid
public static ProcessId FromGuid(Guid value)
Creates a `ProcessId` from an existing `Guid`.
- value: Guid
- The underlying unique identifier GUID.
Returns: A new `ProcessId` instance.
methodNewId
public static ProcessId NewId()
Creates a new `ProcessId` from a time-ordered UUIDv7.
Returns: A new unique `ProcessId`.
methodParse
public static ProcessId Parse(ReadOnlySpan<byte> utf8Text)
Parses a span of UTF-8 bytes into a `ProcessId`.
- utf8Text: ReadOnlySpan<byte>
- The span of UTF-8 bytes to parse.
Returns: The parsed `ProcessId`.
methodParse
public static ProcessId Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
methodParse
public static ProcessId Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `ProcessId`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `ProcessId`.
methodParse
public static ProcessId Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static ProcessId Parse(string s)
Parses a string into a `ProcessId`.
- s: string
- The string to parse.
Returns: The parsed `ProcessId`.
methodParse
public static ProcessId Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToGuid
public Guid ToGuid()
Converts this instance to its underlying `Guid` value.
Returns: The underlying `Guid` value.
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out ProcessId result)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
- result: out ProcessId
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ProcessId result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out ProcessId
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out ProcessId result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out ProcessId
methodexplicit operator ProcessId
public static explicit operator ProcessId(Guid value)
Converts a `Guid` to a `ProcessId` instance.
- value: Guid
- The unique identifier GUID.
methodimplicit operator Guid
public static implicit operator Guid(ProcessId id)
Converts a `ProcessId` to its underlying `Guid` value.
- id: ProcessId
- The process identifier to convert.
methodoperator <
public static bool operator <(ProcessId left, ProcessId right)
Determines whether one `ProcessId` instance is less than another.
- left: ProcessId
- The first process identifier to compare.
- right: ProcessId
- The second process identifier to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(ProcessId left, ProcessId right)
Determines whether one `ProcessId` instance is less than or equal to another.
- left: ProcessId
- The first process identifier to compare.
- right: ProcessId
- The second process identifier to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(ProcessId left, ProcessId right)
Determines whether one `ProcessId` instance is greater than another.
- left: ProcessId
- The first process identifier to compare.
- right: ProcessId
- The second process identifier to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(ProcessId left, ProcessId right)
Determines whether one `ProcessId` instance is greater than or equal to another.
- left: ProcessId
- The first process identifier to compare.
- right: ProcessId
- The second process identifier to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyEmpty
public static ProcessId Empty { get; }
Gets an empty `ProcessId`.
propertyValue
public Guid Value { get; }
Gets the underlying `Guid` value.
record
ProcessInstance<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record ProcessInstance<TState> where TState : notnull
Represents a persistent container that encapsulates execution metadata alongside the domain state.
Members (16)
constructorProcessInstance
public ProcessInstance(ProcessId id, ProcessType type, ProcessVersion version, ProcessStatus status, Revision revision, CorrelationId correlationId, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? completedAt, TState state, IReadOnlyList<CompensationStep>? recordedCompensations = null)
Initializes a new instance of the `ProcessInstance<TState>` record with the specified metadata and domain state.
- id: ProcessId
- The unique identifier of the process instance.
- type: ProcessType
- The logical process type identifier.
- version: ProcessVersion
- The schema or definition version.
- status: ProcessStatus
- The lifecycle execution status.
- revision: Revision
- The optimistic concurrency revision token.
- correlationId: CorrelationId
- The business correlation identifier.
- createdAt: DateTimeOffset
- The UTC creation timestamp.
- updatedAt: DateTimeOffset
- The UTC last-updated timestamp.
- completedAt: DateTimeOffset?
- The optional UTC completion timestamp.
- state: TState
- The immutable domain state payload.
- recordedCompensations: IReadOnlyList<CompensationStep>?
- The optional list of recorded compensation steps.
methodAdvance
public ProcessInstance<TState> Advance(TState newState, ProcessStatus newStatus, DateTimeOffset now, IReadOnlyList<CompensationStep>? newCompensations = null, int maxCompensations = 1000)
Advances the process instance to a new state and status with an incremented revision.
- newState: TState
- The updated domain state payload.
- newStatus: ProcessStatus
- The updated lifecycle status.
- now: DateTimeOffset
- The current UTC timestamp.
- newCompensations: IReadOnlyList<CompensationStep>?
- The optional new compensation steps recorded during this transition.
- maxCompensations: int
- The maximum allowed compensations before throwing an exception. Defaults to 1000.
Returns: A new `ProcessInstance<TState>` record representing the advanced state.
methodAdvanceCompensation
public ProcessInstance<TState> AdvanceCompensation(TState newState, ProcessStatus newStatus, DateTimeOffset now, IReadOnlyList<CompensationStep>? updatedCompensations = null)
Advances the process instance to a new state during a compensation step, updating recorded compensations.
- newState: TState
- The updated domain state payload.
- newStatus: ProcessStatus
- The updated lifecycle status.
- now: DateTimeOffset
- The current UTC timestamp.
- updatedCompensations: IReadOnlyList<CompensationStep>?
- The optional explicit list of compensation steps after this step. When `null` and status is not `ProcessStatus.Failed`, removes the last recorded step.
Returns: A new `ProcessInstance<TState>` record representing the advanced state.
methodCreate
public static ProcessInstance<TState> Create(ProcessId id, ProcessType type, ProcessVersion version, CorrelationId correlationId, TState initialState, DateTimeOffset now)
Creates a new `ProcessInstance<TState>` in the initialized status with the initial revision.
- id: ProcessId
- The unique process identifier.
- type: ProcessType
- The logical process type identifier.
- version: ProcessVersion
- The schema or definition version.
- correlationId: CorrelationId
- The business correlation identifier.
- initialState: TState
- The initial domain state payload.
- now: DateTimeOffset
- The current UTC timestamp.
Returns: A new `ProcessInstance<TState>` instance.
methodIsValidTransition
public static bool IsValidTransition(ProcessStatus current, ProcessStatus next)
Determines whether a transition from `current` to `next` is valid in the process lifecycle FSM.
- current: ProcessStatus
- The current process status.
- next: ProcessStatus
- The target process status.
Returns: `true` if the transition is permitted; otherwise, `false`.
propertyCompletedAt
public DateTimeOffset? CompletedAt { get; init; }
Gets the UTC timestamp when the process reached a terminal status, if any.
propertyCorrelationId
public CorrelationId CorrelationId { get; init; }
Gets the business correlation identifier associated with this instance.
propertyCreatedAt
public DateTimeOffset CreatedAt { get; init; }
Gets the UTC timestamp when the process instance was created.
propertyId
public ProcessId Id { get; init; }
Gets the unique identifier of the process instance.
propertyRecordedCompensations
public IReadOnlyList<CompensationStep> RecordedCompensations { get; init; }
Gets the list of recorded compensation steps, if any.
propertyRevision
public Revision Revision { get; init; }
Gets the optimistic concurrency revision token.
propertyState
public TState State { get; init; }
Gets the immutable domain state payload.
propertyStatus
public ProcessStatus Status { get; init; }
Gets the current lifecycle status of the process instance.
propertyType
public ProcessType Type { get; init; }
Gets the logical process type identifier.
propertyUpdatedAt
public DateTimeOffset UpdatedAt { get; init; }
Gets the UTC timestamp when the process instance was last updated.
propertyVersion
public ProcessVersion Version { get; init; }
Gets the schema or definition version of the process instance.
class
ProcessNotFoundException
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class ProcessNotFoundException : ProcessException
Inherits: ProcessException
Represents errors caused by attempting to access a process instance that was not found in storage.
Members (5)
constructorProcessNotFoundException
public ProcessNotFoundException()
Initializes a new instance of the `ProcessNotFoundException` class.
constructorProcessNotFoundException
public ProcessNotFoundException(ProcessId processId)
Initializes a new instance of the `ProcessNotFoundException` class for the specified process identifier.
- processId: ProcessId
- The unique process identifier that was not found.
constructorProcessNotFoundException
public ProcessNotFoundException(string message)
Initializes a new instance of the `ProcessNotFoundException` class with a specified error message.
- message: string
- The message that describes the error.
constructorProcessNotFoundException
public ProcessNotFoundException(string message, Exception? innerException)
Initializes a new instance of the `ProcessNotFoundException` class with a specified error message and inner exception.
- message: string
- The error message that explains the reason for the exception.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
constructorProcessNotFoundException
public ProcessNotFoundException(string message, ProcessId processId, Exception? innerException = null)
Initializes a new instance of the `ProcessNotFoundException` class with a specified error message and process identifier.
- message: string
- The message that describes the error.
- processId: ProcessId
- The unique process identifier that was not found.
- innerException: Exception?
- The exception that is the cause of the current exception, or `null`.
enum
ProcessSaveResult
Assembly: EricksonLopez.Processes.Abstractionspublic enum ProcessSaveResult
Specifies the outcome of saving a process instance to durable storage.
Members (4)
fieldConcurrencyConflict
ConcurrencyConflict = 1
Specifies that an optimistic concurrency conflict occurred because the stored revision did not match the expected revision.
fieldNotFound
NotFound = 2
Specifies that the target process instance was not found in storage.
fieldPersistenceError
PersistenceError = 3
Specifies that a storage or network infrastructure error occurred during persistence.
fieldSuccess
Success = 0
Specifies that the process instance was successfully created or updated with a matching revision token.
record
ProcessStateRecord
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record ProcessStateRecord
Represents a flat, schema-agnostic storage record of a process instance for database engines.
Members (11)
propertyCompletedAt
public DateTimeOffset? CompletedAt { get; init; }
Gets the UTC timestamp when the process reached a terminal status, if any.
propertyCorrelationId
public required string CorrelationId { get; init; }
Gets the business correlation identifier.
propertyCreatedAt
public required DateTimeOffset CreatedAt { get; init; }
Gets the UTC timestamp when the process instance was created.
propertyProcessId
public required string ProcessId { get; init; }
Gets the unique process instance identifier as a string.
propertyProcessType
public required string ProcessType { get; init; }
Gets the logical process type name or identifier.
propertyRecordedCompensationsPayload
public string RecordedCompensationsPayload { get; init; }
Gets the serialized JSON array of recorded compensation steps.
propertyRevision
public required long Revision { get; init; }
Gets the optimistic concurrency revision integer token.
propertyStatePayload
public required string StatePayload { get; init; }
Gets the serialized state payload string.
propertyStatus
public required int Status { get; init; }
Gets the integer representation of the lifecycle execution status.
propertyUpdatedAt
public required DateTimeOffset UpdatedAt { get; init; }
Gets the UTC timestamp when the process instance was last updated.
propertyVersion
public required string Version { get; init; }
Gets the schema or definition version string.
enum
ProcessStatus
Assembly: EricksonLopez.Processes.Abstractionspublic enum ProcessStatus
Specifies the lifecycle execution status of a process or saga instance.
Members (7)
fieldCompensated
Compensated = 5
Specifies that all compensating actions completed successfully in a terminal state.
fieldCompensating
Compensating = 4
Specifies that an error occurred and compensating actions are actively executing.
fieldCompleted
Completed = 3
Specifies that the process has successfully finished all steps and reached a terminal state.
fieldFailed
Failed = 6
Specifies that the process encountered an unrecoverable failure requiring intervention.
fieldInitialized
Initialized = 0
Specifies that the process instance is created and initialized, but has not yet processed triggers.
fieldRunning
Running = 1
Specifies that the process is actively executing forward workflow steps.
fieldSuspended
Suspended = 2
Specifies that the process is suspended, awaiting external input, manual approval, or a timer.
record
ProcessTransitionResult<TState>
Assembly: EricksonLopez.Processes.Abstractionspublic sealed record ProcessTransitionResult<TState> where TState : notnull
Represents the outcome of handling an event within a process manager or saga.
Members (13)
constructorProcessTransitionResult
public ProcessTransitionResult(TState state, ProcessStatus status, IReadOnlyList<ProcessEffect>? effects = null, IReadOnlyList<CompensationStep>? recordedCompensations = null, string? failureReason = null)
Initializes a new instance of the `ProcessTransitionResult<TState>` record with state, status, and side effects.
- state: TState
- The updated domain state.
- status: ProcessStatus
- The target lifecycle status.
- effects: IReadOnlyList<ProcessEffect>?
- The optional list of emitted side-effect intents.
- recordedCompensations: IReadOnlyList<CompensationStep>?
- The optional list of recorded compensation steps.
- failureReason: string?
- The optional failure reason explanation.
methodAdvance
public static ProcessTransitionResult<TState> Advance(TState state, ProcessStatus status = ProcessStatus.Running, IEnumerable<ProcessEffect>? effects = null, IEnumerable<CompensationStep>? recordedCompensations = null)
Advances the process to a new state and status.
- state: TState
- The updated domain state.
- status: ProcessStatus
- The target lifecycle status (defaults to `ProcessStatus.Running`).
- effects: IEnumerable<ProcessEffect>?
- The optional side-effect intents to emit.
- recordedCompensations: IEnumerable<CompensationStep>?
- The optional compensation steps to record.
Returns: A new `ProcessTransitionResult<TState>` instance.
methodCompensate
public static ProcessTransitionResult<TState> Compensate(TState state, IEnumerable<CompensationAction>? compensationActions = null)
Transitions the saga to the `ProcessStatus.Compensating` state and emits compensating intents.
- state: TState
- The current domain state.
- compensationActions: IEnumerable<CompensationAction>?
- The optional compensation actions to trigger.
Returns: A new `ProcessTransitionResult<TState>` instance.
methodCompensated
public static ProcessTransitionResult<TState> Compensated(TState state, IEnumerable<ProcessEffect>? effects = null)
Transitions the saga to the `ProcessStatus.Compensated` terminal state after all compensations execute.
- state: TState
- The compensated domain state.
- effects: IEnumerable<ProcessEffect>?
- The optional side-effect intents to emit.
Returns: A new `ProcessTransitionResult<TState>` instance.
methodComplete
public static ProcessTransitionResult<TState> Complete(TState state, IEnumerable<ProcessEffect>? effects = null, IEnumerable<CompensationStep>? recordedCompensations = null)
Transitions the process to the `ProcessStatus.Completed` terminal state.
- state: TState
- The final domain state.
- effects: IEnumerable<ProcessEffect>?
- The optional side-effect intents to emit.
- recordedCompensations: IEnumerable<CompensationStep>?
- The optional compensation steps to record.
Returns: A new `ProcessTransitionResult<TState>` instance.
methodFail
public static ProcessTransitionResult<TState> Fail(TState state, string reason, IEnumerable<ProcessEffect>? effects = null)
Transitions the process to the `ProcessStatus.Failed` terminal or escalated state.
- state: TState
- The failed domain state.
- reason: string
- The reason describing why the transition failed.
- effects: IEnumerable<ProcessEffect>?
- The optional side-effect intents to emit.
Returns: A new `ProcessTransitionResult<TState>` instance.
methodSuspend
public static ProcessTransitionResult<TState> Suspend(TState state, IEnumerable<ProcessEffect>? effects = null)
Transitions the process to the `ProcessStatus.Suspended` state awaiting external confirmation or a timer.
- state: TState
- The suspended domain state.
- effects: IEnumerable<ProcessEffect>?
- The optional side-effect intents to emit.
Returns: A new `ProcessTransitionResult<TState>` instance.
methodUnchanged
public static ProcessTransitionResult<TState> Unchanged(TState state, ProcessStatus currentStatus = ProcessStatus.Running)
Returns a transition result that preserves the existing state and status without changes.
- state: TState
- The current domain state.
- currentStatus: ProcessStatus
- The current lifecycle status.
Returns: A new `ProcessTransitionResult<TState>` instance.
propertyEffects
public IReadOnlyList<ProcessEffect> Effects { get; init; }
Gets the list of side-effect intents emitted by this transition.
propertyFailureReason
public string? FailureReason { get; init; }
Gets the reason for failure if the process transitioned to `ProcessStatus.Failed`.
propertyRecordedCompensations
public IReadOnlyList<CompensationStep> RecordedCompensations { get; init; }
Gets the list of newly recorded compensation steps produced by forward step execution.
propertyState
public TState State { get; init; }
Gets the updated domain state.
propertyStatus
public ProcessStatus Status { get; init; }
Gets the new lifecycle status of the process instance.
record
ProcessType
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct ProcessType : IComparable<ProcessType>, IComparable, ISpanFormattable, ISpanParsable<ProcessType>
Implements: IComparable, IComparable<ProcessType>, ISpanFormattable, ISpanParsable<ProcessType>
Represents the logical, immutable name and category of a process definition.
Members (21)
constructorProcessType
public ProcessType(string value)
Initializes a new instance of the `ProcessType` struct with the specified logical process type name.
- value: string
- The logical process type name.
methodCompareTo
public int CompareTo(ProcessType other)
Inherits documentation from base type or interface.
- other: ProcessType
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static ProcessType From(string value)
Creates a `ProcessType` from the specified string value.
- value: string
- The logical process type name.
Returns: A new `ProcessType` instance.
methodFromString
public static ProcessType FromString(string value)
Creates a `ProcessType` from the specified string value.
- value: string
- The logical process type name.
Returns: A new `ProcessType` instance.
methodParse
public static ProcessType Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `ProcessType`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `ProcessType`.
methodParse
public static ProcessType Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static ProcessType Parse(string s)
Parses a string into a `ProcessType`.
- s: string
- The string to parse.
Returns: The parsed `ProcessType`.
methodParse
public static ProcessType Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ProcessType result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out ProcessType
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out ProcessType result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out ProcessType
methodexplicit operator ProcessType
public static explicit operator ProcessType(string value)
Converts a string to a `ProcessType` instance.
- value: string
- The logical process type name.
methodimplicit operator string
public static implicit operator string(ProcessType type)
Converts a `ProcessType` to its underlying string representation.
- type: ProcessType
- The process type to convert.
methodoperator <
public static bool operator <(ProcessType left, ProcessType right)
Determines whether one `ProcessType` instance is less than another.
- left: ProcessType
- The first process type to compare.
- right: ProcessType
- The second process type to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(ProcessType left, ProcessType right)
Determines whether one `ProcessType` instance is less than or equal to another.
- left: ProcessType
- The first process type to compare.
- right: ProcessType
- The second process type to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(ProcessType left, ProcessType right)
Determines whether one `ProcessType` instance is greater than another.
- left: ProcessType
- The first process type to compare.
- right: ProcessType
- The second process type to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(ProcessType left, ProcessType right)
Determines whether one `ProcessType` instance is greater than or equal to another.
- left: ProcessType
- The first process type to compare.
- right: ProcessType
- The second process type to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyValue
public string Value { get; }
Gets the string token representing the process type.
class
ProcessTypeAttribute
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class ProcessTypeAttribute : Attribute
Inherits: Attribute
Specifies the logical process type identifier for a process state or definition class.
Members (2)
constructorProcessTypeAttribute
public ProcessTypeAttribute(string processType)
Initializes a new instance of the `ProcessTypeAttribute` class with the specified process type.
- processType: string
- The logical process type identifier.
propertyProcessType
public string ProcessType { get; }
Gets the unique logical process type identifier.
record
ProcessVersion
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct ProcessVersion : IComparable<ProcessVersion>, IComparable, ISpanFormattable, ISpanParsable<ProcessVersion>, IUtf8SpanParsable<ProcessVersion>
Implements: IComparable, IComparable<ProcessVersion>, ISpanFormattable, ISpanParsable<ProcessVersion>, IUtf8SpanParsable<ProcessVersion>
Represents the schema and definition version of a process.
Members (27)
constructorProcessVersion
public ProcessVersion(int value)
Initializes a new instance of the `ProcessVersion` struct with the specified version number.
- value: int
- The version number (must be greater than or equal to 1).
methodCompareTo
public int CompareTo(ProcessVersion other)
Inherits documentation from base type or interface.
- other: ProcessVersion
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static ProcessVersion From(int value)
Creates a `ProcessVersion` from an integer value.
- value: int
- The version number (must be greater than or equal to 1).
Returns: A new `ProcessVersion` instance.
methodFromInt32
public static ProcessVersion FromInt32(int value)
Creates a `ProcessVersion` from an integer value.
- value: int
- The version number (must be greater than or equal to 1).
Returns: A new `ProcessVersion` instance.
methodNext
public ProcessVersion Next()
Returns the next incremented version.
Returns: A new `ProcessVersion` incremented by one.
methodParse
public static ProcessVersion Parse(ReadOnlySpan<byte> utf8Text)
Parses a span of UTF-8 bytes into a `ProcessVersion`.
- utf8Text: ReadOnlySpan<byte>
- The span of UTF-8 bytes to parse.
Returns: The parsed `ProcessVersion`.
methodParse
public static ProcessVersion Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
methodParse
public static ProcessVersion Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `ProcessVersion`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `ProcessVersion`.
methodParse
public static ProcessVersion Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static ProcessVersion Parse(string s)
Parses a string into a `ProcessVersion`.
- s: string
- The string to parse.
Returns: The parsed `ProcessVersion`.
methodParse
public static ProcessVersion Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToInt32
public int ToInt32()
Converts this instance to its integer value.
Returns: The version integer value.
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out ProcessVersion result)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
- result: out ProcessVersion
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out ProcessVersion result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out ProcessVersion
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out ProcessVersion result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out ProcessVersion
methodexplicit operator ProcessVersion
public static explicit operator ProcessVersion(int value)
Converts an integer to a `ProcessVersion` instance.
- value: int
- The version number.
methodimplicit operator int
public static implicit operator int(ProcessVersion version)
Converts a `ProcessVersion` to its integer value.
- version: ProcessVersion
- The process version to convert.
methodoperator <
public static bool operator <(ProcessVersion left, ProcessVersion right)
Determines whether one `ProcessVersion` instance is less than another.
- left: ProcessVersion
- The first process version to compare.
- right: ProcessVersion
- The second process version to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(ProcessVersion left, ProcessVersion right)
Determines whether one `ProcessVersion` instance is less than or equal to another.
- left: ProcessVersion
- The first process version to compare.
- right: ProcessVersion
- The second process version to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(ProcessVersion left, ProcessVersion right)
Determines whether one `ProcessVersion` instance is greater than another.
- left: ProcessVersion
- The first process version to compare.
- right: ProcessVersion
- The second process version to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(ProcessVersion left, ProcessVersion right)
Determines whether one `ProcessVersion` instance is greater than or equal to another.
- left: ProcessVersion
- The first process version to compare.
- right: ProcessVersion
- The second process version to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyInitial
public static ProcessVersion Initial { get; }
Gets the initial version (`1`).
propertyValue
public int Value { get; }
Gets the integer version value.
record
Revision
Assembly: EricksonLopez.Processes.Abstractionspublic readonly record struct Revision : IComparable<Revision>, IComparable, ISpanFormattable, ISpanParsable<Revision>, IUtf8SpanParsable<Revision>
Implements: IComparable, IComparable<Revision>, ISpanFormattable, ISpanParsable<Revision>, IUtf8SpanParsable<Revision>
Represents a monotonically increasing revision token for optimistic concurrency control in state persistence.
Members (28)
constructorRevision
public Revision(long value)
Initializes a new instance of the `Revision` struct with the specified revision value.
- value: long
- The revision value (must be greater than or equal to 0).
methodCompareTo
public int CompareTo(Revision other)
Inherits documentation from base type or interface.
- other: Revision
methodCompareTo
public int CompareTo(object? obj)
Inherits documentation from base type or interface.
- obj: object?
methodFrom
public static Revision From(long value)
Creates a `Revision` from a long integer value.
- value: long
- The revision value (must be greater than or equal to 0).
Returns: A new `Revision` instance.
methodFromInt64
public static Revision FromInt64(long value)
Creates a `Revision` from a long integer value.
- value: long
- The revision value (must be greater than or equal to 0).
Returns: A new `Revision` instance.
methodNext
public Revision Next()
Returns the next incremented revision.
Returns: A new `Revision` incremented by one.
methodParse
public static Revision Parse(ReadOnlySpan<byte> utf8Text)
Parses a span of UTF-8 bytes into a `Revision`.
- utf8Text: ReadOnlySpan<byte>
- The span of UTF-8 bytes to parse.
Returns: The parsed `Revision`.
methodParse
public static Revision Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
methodParse
public static Revision Parse(ReadOnlySpan<char> s)
Parses a span of characters into a `Revision`.
- s: ReadOnlySpan<char>
- The span of characters to parse.
Returns: The parsed `Revision`.
methodParse
public static Revision Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
methodParse
public static Revision Parse(string s)
Parses a string into a `Revision`.
- s: string
- The string to parse.
Returns: The parsed `Revision`.
methodParse
public static Revision Parse(string s, IFormatProvider? provider)
Inherits documentation from base type or interface.
- s: string
- provider: IFormatProvider?
methodToInt64
public long ToInt64()
Converts this instance to its long integer value.
Returns: The revision long integer value.
methodToString
public override string ToString()
Inherits documentation from base type or interface.
methodToString
public string ToString(string? format, IFormatProvider? formatProvider)
Inherits documentation from base type or interface.
- format: string?
- formatProvider: IFormatProvider?
methodTryFormat
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Inherits documentation from base type or interface.
- destination: Span<char>
- charsWritten: out int
- format: ReadOnlySpan<char>
- provider: IFormatProvider?
methodTryParse
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Revision result)
Inherits documentation from base type or interface.
- utf8Text: ReadOnlySpan<byte>
- provider: IFormatProvider?
- result: out Revision
methodTryParse
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Revision result)
Inherits documentation from base type or interface.
- s: ReadOnlySpan<char>
- provider: IFormatProvider?
- result: out Revision
methodTryParse
public static bool TryParse(string? s, IFormatProvider? provider, out Revision result)
Inherits documentation from base type or interface.
- s: string?
- provider: IFormatProvider?
- result: out Revision
methodexplicit operator Revision
public static explicit operator Revision(long value)
Converts a long integer to a `Revision` instance.
- value: long
- The revision value.
methodimplicit operator long
public static implicit operator long(Revision revision)
Converts a `Revision` to its long integer value.
- revision: Revision
- The revision to convert.
methodoperator <
public static bool operator <(Revision left, Revision right)
Determines whether one `Revision` instance is less than another.
- left: Revision
- The first revision to compare.
- right: Revision
- The second revision to compare.
Returns: `true` if `left` is less than `right`; otherwise, `false`.
methodoperator <=
public static bool operator <=(Revision left, Revision right)
Determines whether one `Revision` instance is less than or equal to another.
- left: Revision
- The first revision to compare.
- right: Revision
- The second revision to compare.
Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.
methodoperator >
public static bool operator >(Revision left, Revision right)
Determines whether one `Revision` instance is greater than another.
- left: Revision
- The first revision to compare.
- right: Revision
- The second revision to compare.
Returns: `true` if `left` is greater than `right`; otherwise, `false`.
methodoperator >=
public static bool operator >=(Revision left, Revision right)
Determines whether one `Revision` instance is greater than or equal to another.
- left: Revision
- The first revision to compare.
- right: Revision
- The second revision to compare.
Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.
propertyInitial
public static Revision Initial { get; }
Gets the initial committed revision (`1`).
propertyNone
public static Revision None { get; }
Gets the zero uncommitted revision (`0`).
propertyValue
public long Value { get; }
Gets the long revision value.
class
SagaDefinitionAttribute
Assembly: EricksonLopez.Processes.Abstractionspublic sealed class SagaDefinitionAttribute : Attribute
Inherits: Attribute
Specifies that a class is a saga definition with compensation capabilities discovered for compile-time registration.
Members (3)
constructorSagaDefinitionAttribute
public SagaDefinitionAttribute(string processType, int version = 1)
Initializes a new instance of the `SagaDefinitionAttribute` class with the specified process type and version.
- processType: string
- The logical saga process type identifier.
- version: int
- The schema or definition version number.
propertyProcessType
public string ProcessType { get; }
Gets the unique logical saga process type identifier.
propertyVersion
public int Version { get; }
Gets the schema or definition version number.