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
QueryNameFullyQualifiedQueryNameThe FullyQualifiedQueryName the subscription was established for.
ArgumentsQueryArgumentsThe coerced QueryArguments the subscription was established with.
PrincipalClaimsPrincipalThe ClaimsPrincipal of the caller that established the subscription, or null when the subscription is anonymous.
CorrelationIdCorrelationIdThe CorrelationId the subscription stamps every emission with.
ServiceProviderIServiceProviderThe per-subscription IServiceProvider to resolve guard dependencies from.
IsFirstEmissionboolWhether 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 voidobserver 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.CancellationTokenCancellationTokenThe 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
originalObservableQueryEmissionContext
Properties
Arguments
The coerced QueryArguments the subscription was established with.
public QueryArguments Arguments { get; init; }
Property Value
CancellationToken
The CancellationToken that is cancelled when the subscription ends.
public CancellationToken CancellationToken { get; init; }
Property Value
CorrelationId
The CorrelationId the subscription stamps every emission with.
public CorrelationId CorrelationId { get; init; }
Property Value
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
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
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
Principal
The ClaimsPrincipal of the caller that established the subscription, or null when the subscription is anonymous.
public ClaimsPrincipal? Principal { get; init; }
Property Value
QueryName
The FullyQualifiedQueryName the subscription was established for.
public FullyQualifiedQueryName QueryName { get; init; }
Property Value
ServiceProvider
The per-subscription IServiceProvider to resolve guard dependencies from.
public IServiceProvider ServiceProvider { get; init; }
Property Value
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
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
QueryNameFullyQualifiedQueryNameArgumentsQueryArgumentsPrincipalClaimsPrincipalCorrelationIdCorrelationIdServiceProviderIServiceProviderIsFirstEmissionboolCancellationTokenCancellationToken
Equals(ObservableQueryEmissionContext?)
public virtual bool Equals(ObservableQueryEmissionContext? other)
Parameters
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(ObservableQueryEmissionContext?, ObservableQueryEmissionContext?)
public static bool operator ==(ObservableQueryEmissionContext? left, ObservableQueryEmissionContext? right)
Parameters
Returns
operator !=(ObservableQueryEmissionContext?, ObservableQueryEmissionContext?)
public static bool operator !=(ObservableQueryEmissionContext? left, ObservableQueryEmissionContext? right)