Class ObservableQueryEmissionContext

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

Represents the context handed to an IGuardObservableQueryEmission for a single emission on an observable query subscription.

public record ObservableQueryEmissionContext : IEquatable<ObservableQueryEmissionContext>
Inheritance
ObservableQueryEmissionContext
Implements
Inherited Members
Extension Methods

Remarks

The principal is passed explicitly rather than resolved ambiently. Emissions arrive on the producing stream's own thread, where the request's AsyncLocal context does not flow, so a guard that reached for an ambient accessor would see whichever identity — or none — that thread happened to carry.

For a WebSocket subscription the principal is selected from authentication schemes on the live handshake when the subscription is admitted, then captured for its lifetime. The WebSocket protocol offers no way to re-present credentials on an established connection, so it does not change after admission. A guard that needs a fresher verdict must reach its own source of truth (a session store, a token introspection endpoint, a revocation list) using the identity carried here.

Constructors

ObservableQueryEmissionContext(FullyQualifiedQueryName, QueryArguments, ClaimsPrincipal?, CorrelationId, IServiceProvider, bool, CancellationToken)

Represents the context handed to an IGuardObservableQueryEmission for a single emission on an observable query subscription.

public ObservableQueryEmissionContext(FullyQualifiedQueryName QueryName, QueryArguments Arguments, ClaimsPrincipal? Principal, CorrelationId CorrelationId, IServiceProvider ServiceProvider, bool IsFirstEmission, CancellationToken CancellationToken)

Parameters

QueryName FullyQualifiedQueryName

The FullyQualifiedQueryName the subscription was established for.

Arguments QueryArguments

The coerced QueryArguments the subscription was established with.

Principal ClaimsPrincipal

The ClaimsPrincipal of the caller that established the subscription, or null when the subscription is anonymous.

CorrelationId CorrelationId

The CorrelationId the subscription stamps every emission with.

ServiceProvider IServiceProvider

The per-subscription IServiceProvider to resolve guard dependencies from.

IsFirstEmission bool

Whether this is the first emission delivered on the subscription. On the direct (non-multiplexed) transports this is best-effort: emissions are dispatched from an async void observer with no serializing gate, so two emissions racing each other can both be told they are the first. Treat it as a hint for doing extra work once, never as the sole basis for a security decision.

CancellationToken CancellationToken

The CancellationToken that is cancelled when the subscription ends.

Remarks

The principal is passed explicitly rather than resolved ambiently. Emissions arrive on the producing stream's own thread, where the request's AsyncLocal context does not flow, so a guard that reached for an ambient accessor would see whichever identity — or none — that thread happened to carry.

For a WebSocket subscription the principal is selected from authentication schemes on the live handshake when the subscription is admitted, then captured for its lifetime. The WebSocket protocol offers no way to re-present credentials on an established connection, so it does not change after admission. A guard that needs a fresher verdict must reach its own source of truth (a session store, a token introspection endpoint, a revocation list) using the identity carried here.

ObservableQueryEmissionContext(ObservableQueryEmissionContext)

protected ObservableQueryEmissionContext(ObservableQueryEmissionContext original)

Parameters

original ObservableQueryEmissionContext

Properties

Arguments

The coerced QueryArguments the subscription was established with.

public QueryArguments Arguments { get; init; }

Property Value

QueryArguments

CancellationToken

The CancellationToken that is cancelled when the subscription ends.

public CancellationToken CancellationToken { get; init; }

Property Value

CancellationToken

CorrelationId

The CorrelationId the subscription stamps every emission with.

public CorrelationId CorrelationId { get; init; }

Property Value

CorrelationId

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

IsFirstEmission

Whether this is the first emission delivered on the subscription. On the direct (non-multiplexed) transports this is best-effort: emissions are dispatched from an async void observer with no serializing gate, so two emissions racing each other can both be told they are the first. Treat it as a hint for doing extra work once, never as the sole basis for a security decision.

public bool IsFirstEmission { get; init; }

Property Value

bool

IsSnapshot

Gets whether this emission is a one-shot result delivered through the query hub rather than a stream.

public bool IsSnapshot { get; init; }

Property Value

bool

Principal

The ClaimsPrincipal of the caller that established the subscription, or null when the subscription is anonymous.

public ClaimsPrincipal? Principal { get; init; }

Property Value

ClaimsPrincipal

QueryName

The FullyQualifiedQueryName the subscription was established for.

public FullyQualifiedQueryName QueryName { get; init; }

Property Value

FullyQualifiedQueryName

ServiceProvider

The per-subscription IServiceProvider to resolve guard dependencies from.

public IServiceProvider ServiceProvider { get; init; }

Property Value

IServiceProvider

SubscriptionScope

Gets the independent snapshot of the scope selected by the query filters at subscription time, or null if no scope was supplied.

public object? SubscriptionScope { get; init; }

Property Value

object

Methods

Deconstruct(out FullyQualifiedQueryName, out QueryArguments, out ClaimsPrincipal?, out CorrelationId, out IServiceProvider, out bool, out CancellationToken)

public void Deconstruct(out FullyQualifiedQueryName QueryName, out QueryArguments Arguments, out ClaimsPrincipal? Principal, out CorrelationId CorrelationId, out IServiceProvider ServiceProvider, out bool IsFirstEmission, out CancellationToken CancellationToken)

Parameters

QueryName FullyQualifiedQueryName
Arguments QueryArguments
Principal ClaimsPrincipal
CorrelationId CorrelationId
ServiceProvider IServiceProvider
IsFirstEmission bool
CancellationToken CancellationToken

Equals(ObservableQueryEmissionContext?)

public virtual bool Equals(ObservableQueryEmissionContext? other)

Parameters

other ObservableQueryEmissionContext

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ObservableQueryEmissionContext?, ObservableQueryEmissionContext?)

public static bool operator ==(ObservableQueryEmissionContext? left, ObservableQueryEmissionContext? right)

Parameters

left ObservableQueryEmissionContext
right ObservableQueryEmissionContext

Returns

bool

operator !=(ObservableQueryEmissionContext?, ObservableQueryEmissionContext?)

public static bool operator !=(ObservableQueryEmissionContext? left, ObservableQueryEmissionContext? right)

Parameters

left ObservableQueryEmissionContext
right ObservableQueryEmissionContext

Returns

bool