Table of Contents

Class FailureScenarioSaveChangesInterceptor

Namespace
ReferenceApplication.Web.Governance.FailureScenarios
Assembly
ReferenceApplication.Web.dll

Fails a database save, as a provider failure would, for the write an armed scenario targets.

public sealed class FailureScenarioSaveChangesInterceptor : SaveChangesInterceptor, ISaveChangesInterceptor, IInterceptor
Inheritance
FailureScenarioSaveChangesInterceptor
Implements
Inherited Members

Remarks

The fault is injected at the persistence layer, so the code under demonstration handles a real DbUpdateException: AsiBackbone's ledger store and the decision-receipt sink for a failed ledger append, NCAT's audited transaction for a failed mutation, and the audit-completion publisher for a failed lifecycle append.

  • Ledger append fails: a save that adds a ledger record during the armed request.
  • Execution fails after approval: a save that adds a governed record during the armed request.
  • Outbox delivery fails: a save that adds the lifecycle event for the armed request's correlation, until the run's delivery fault is cleared. Delivery runs on the outbox worker, outside any request.

Constructors

FailureScenarioSaveChangesInterceptor(IHttpContextAccessor, FailureScenarioRegistry)

Fails a database save, as a provider failure would, for the write an armed scenario targets.

public FailureScenarioSaveChangesInterceptor(IHttpContextAccessor httpContextAccessor, FailureScenarioRegistry registry)

Parameters

httpContextAccessor IHttpContextAccessor

The current request accessor.

registry FailureScenarioRegistry

The run registry.

Remarks

The fault is injected at the persistence layer, so the code under demonstration handles a real DbUpdateException: AsiBackbone's ledger store and the decision-receipt sink for a failed ledger append, NCAT's audited transaction for a failed mutation, and the audit-completion publisher for a failed lifecycle append.

  • Ledger append fails: a save that adds a ledger record during the armed request.
  • Execution fails after approval: a save that adds a governed record during the armed request.
  • Outbox delivery fails: a save that adds the lifecycle event for the armed request's correlation, until the run's delivery fault is cleared. Delivery runs on the outbox worker, outside any request.

Methods

SavingChanges(DbContextEventData, InterceptionResult<int>)

Fails the save, before EF Core persists the tracked changes, when it is the write an armed scenario targets. Every other save passes through unchanged.

public override InterceptionResult<int> SavingChanges(DbContextEventData eventData, InterceptionResult<int> result)

Parameters

eventData DbContextEventData

Contextual information about the save operation.

result InterceptionResult<int>

The current interception result, returned unchanged.

Returns

InterceptionResult<int>

The result supplied by EF Core.

Exceptions

DbUpdateException

The save is the write an armed scenario targets.

SavingChangesAsync(DbContextEventData, InterceptionResult<int>, CancellationToken)

Fails the save, before EF Core asynchronously persists the tracked changes, when it is the write an armed scenario targets. Every other save passes through unchanged.

public override ValueTask<InterceptionResult<int>> SavingChangesAsync(DbContextEventData eventData, InterceptionResult<int> result, CancellationToken cancellationToken = default)

Parameters

eventData DbContextEventData

Contextual information about the save operation.

result InterceptionResult<int>

The current interception result, returned unchanged.

cancellationToken CancellationToken

A token that can cancel the operation.

Returns

ValueTask<InterceptionResult<int>>

The result supplied by EF Core.

Exceptions

DbUpdateException

The save is the write an armed scenario targets.