Table of Contents

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

timeProvider TimeProvider

The 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

scenarioId string

The scenario the run belongs to.

actorId string

The governance actor who may send the request.

request FailureScenarioRequest

The 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

runId string

The run identifier.

Returns

bool

true when the run held an active delivery fault.

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

runId string

The run identifier.

statusCode int

The response status code.

exceptionType string

The type of the exception that ended the request, when one did.

reasonCode string

The sanitized reason code the exception carried, when it carried one.

Find(string)

Finds a run.

public FailureScenarioRunState? Find(string runId)

Parameters

runId string

The 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

correlationId string

The correlation identifier of the completion being delivered.

Returns

string

The run identifier, or null when no active delivery fault applies.

RecordFault(string, string)

Records that a fault-injection seam acted for a run.

public void RecordFault(string runId, string faultPoint)

Parameters

runId string

The run identifier.

faultPoint string

Where the fault was injected.

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

runId string

The run identifier from the request header.

actorId string

The governance actor sending the request.

correlationId string

The request's governance correlation identifier.

Returns

FailureScenarioRunState

The run, or null when no unexpired run is armed under that identifier for the actor.