Class FailureScenarioRegistry
- Namespace
- ReferenceApplication.Web.Governance.FailureScenarios
- Assembly
- ReferenceApplication.Web.dll
Holds the armed and completed failure-scenario runs of this process, and the delivery faults they hold.
public sealed class FailureScenarioRegistry
- Inheritance
-
FailureScenarioRegistry
- Inherited Members
Remarks
A run is armed for one actor and one request. TryBegin(string, string, string) consumes it, so the request that carries its identifier is the only one a fault-injection seam can act on, and a second request with the same identifier is refused. An armed run expires after ArmLifetime.
The registry is in memory and bounded to RetainedRunCount runs. Nothing about a run is persisted: its evidence is whatever the governed request left in the demonstration database.
Constructors
FailureScenarioRegistry(TimeProvider)
Holds the armed and completed failure-scenario runs of this process, and the delivery faults they hold.
public FailureScenarioRegistry(TimeProvider timeProvider)
Parameters
timeProviderTimeProviderThe clock that arms and expires runs.
Remarks
A run is armed for one actor and one request. TryBegin(string, string, string) consumes it, so the request that carries its identifier is the only one a fault-injection seam can act on, and a second request with the same identifier is refused. An armed run expires after ArmLifetime.
The registry is in memory and bounded to RetainedRunCount runs. Nothing about a run is persisted: its evidence is whatever the governed request left in the demonstration database.
Methods
Arm(string, string, FailureScenarioRequest)
Arms a run for one request by one actor.
public FailureScenarioRunState Arm(string scenarioId, string actorId, FailureScenarioRequest request)
Parameters
scenarioIdstringThe scenario the run belongs to.
actorIdstringThe governance actor who may send the request.
requestFailureScenarioRequestThe request to send, without the run header, which this method adds.
Returns
- FailureScenarioRunState
The armed run.
ClearDeliveryFault(string)
Clears a run's delivery fault, so the next delivery attempt can succeed.
public bool ClearDeliveryFault(string runId)
Parameters
runIdstringThe run identifier.
Returns
Complete(string, int, string?, string?)
Records how the run's request ended.
public void Complete(string runId, int statusCode, string? exceptionType = null, string? reasonCode = null)
Parameters
runIdstringThe run identifier.
statusCodeintThe response status code.
exceptionTypestringThe type of the exception that ended the request, when one did.
reasonCodestringThe sanitized reason code the exception carried, when it carried one.
Find(string)
Finds a run.
public FailureScenarioRunState? Find(string runId)
Parameters
runIdstringThe run identifier.
Returns
- FailureScenarioRunState
The run, or null when it is unknown or was forgotten.
FindDeliveryFault(string?)
Finds the run whose delivery fault applies to an audit completion.
public string? FindDeliveryFault(string? correlationId)
Parameters
correlationIdstringThe correlation identifier of the completion being delivered.
Returns
RecordFault(string, string)
Records that a fault-injection seam acted for a run.
public void RecordFault(string runId, string faultPoint)
Parameters
TryBegin(string, string, string)
Consumes an armed run for the request that carries its identifier.
public FailureScenarioRunState? TryBegin(string runId, string actorId, string correlationId)
Parameters
runIdstringThe run identifier from the request header.
actorIdstringThe governance actor sending the request.
correlationIdstringThe request's governance correlation identifier.
Returns
- FailureScenarioRunState
The run, or null when no unexpired run is armed under that identifier for the actor.