Interface IGuardObservableQueryEmission

Namespace
Cratis.Arc.Queries
Assembly
Cratis.Arc.Core.dll

Defines a guard that is consulted for every emission an observable query subscription is about to write.

public interface IGuardObservableQueryEmission
Extension Methods

Remarks

Authorization for an observable query is evaluated by the query pipeline when the subscription is established; that verdict gates obtaining the stream. A subscription can then stay open indefinitely, so implement this interface when a verdict must be re-checked while the stream is running — an expired token, an ended session, a revoked role.

Guards are opt-in and discovered by convention: implement the interface and it is picked up. With no implementation present, nothing is dispatched and emissions take the same path they always did.

Every emission calls this, so keep the implementation fast and prefer cached state over per-emission network calls. A guard that throws fails closed — the emission is dropped and the subscription is terminated.

Methods

Guard(ObservableQueryEmissionContext)

Decides what should happen to an emission that is about to be written to the client.

Task<ObservableQueryEmissionVerdict> Guard(ObservableQueryEmissionContext context)

Parameters

context ObservableQueryEmissionContext

The ObservableQueryEmissionContext describing the emission.

Returns

Task<ObservableQueryEmissionVerdict>

The ObservableQueryEmissionVerdict for the emission.