Class ObservableQueryEmissionGuards
- Namespace
- Cratis.Arc.Queries
- Assembly
- Cratis.Arc.Core.dll
Represents an implementation of IObservableQueryEmissionGuards.
[Singleton]
public class ObservableQueryEmissionGuards : IObservableQueryEmissionGuards
- Inheritance
-
ObservableQueryEmissionGuards
- Implements
- Inherited Members
- Extension Methods
Remarks
The guard types are discovered once; the instances are created per emission from the per-subscription service provider carried on the ObservableQueryEmissionContext. Resolving them from the root provider instead would hand a guard whatever scoped collaborator happened to be cached there first, which for a tenant-resolving or session-reading guard is the wrong answer rather than a missing one.
Constructors
ObservableQueryEmissionGuards(ITypes, ILogger<ObservableQueryEmissionGuards>)
Initializes a new instance of the ObservableQueryEmissionGuards class with Arc's default serializer options.
public ObservableQueryEmissionGuards(ITypes types, ILogger<ObservableQueryEmissionGuards> logger)
Parameters
typesITypesThe types used to discover guards.
loggerILogger<ObservableQueryEmissionGuards>The logger.
ObservableQueryEmissionGuards(ITypes, IOptions<ArcOptions>, ILogger<ObservableQueryEmissionGuards>)
Represents an implementation of IObservableQueryEmissionGuards.
public ObservableQueryEmissionGuards(ITypes types, IOptions<ArcOptions> arcOptions, ILogger<ObservableQueryEmissionGuards> logger)
Parameters
typesITypesThe ITypes used to discover IGuardObservableQueryEmission implementations.
arcOptionsIOptions<ArcOptions>The Arc options that provide the configured JSON serializer.
loggerILogger<ObservableQueryEmissionGuards>The logger.
Remarks
The guard types are discovered once; the instances are created per emission from the per-subscription service provider carried on the ObservableQueryEmissionContext. Resolving them from the root provider instead would hand a guard whatever scoped collaborator happened to be cached there first, which for a tenant-resolving or session-reading guard is the wrong answer rather than a missing one.
Properties
HasGuards
Gets a value indicating whether any IGuardObservableQueryEmission implementation exists.
public bool HasGuards { get; }
Property Value
Remarks
Emission paths check this before doing any work for a guard, so an application without guards pays nothing per emission — no context is built and no dispatch happens.
Methods
Guard(ObservableQueryEmissionContext)
Asks every discovered guard about an emission and aggregates their verdicts.
public Task<ObservableQueryEmissionVerdict> Guard(ObservableQueryEmissionContext context)
Parameters
contextObservableQueryEmissionContextThe ObservableQueryEmissionContext describing the emission.
Returns
- Task<ObservableQueryEmissionVerdict>
The most restrictive ObservableQueryEmissionVerdict any guard returned.
Remarks
The aggregate is most-restrictive-wins, and the first DenyAndTerminate short-circuits the remaining guards. A guard that throws is treated as DenyAndTerminate — the failure is logged and never rethrown, because a guard that fails open would leave an application believing it is protected.