Skip to main content

SubscriptionState

Struct SubscriptionState 

Source
pub struct SubscriptionState {
    pub manager: Arc<SubscriptionManager>,
    pub lifecycle: Arc<dyn SubscriptionLifecycle>,
    pub max_subscriptions_per_connection: Option<u32>,
    pub remote_subscription_fields: Arc<HashMap<String, String>>,
    pub domain_registry: Option<Arc<DomainRegistry>>,
    pub strict_tenant_validation: bool,
    pub authorizer: Option<Arc<dyn Authorizer>>,
    pub tenant_status_source: Option<Arc<dyn TenantStatusSource>>,
}
Expand description

State for subscription WebSocket handler.

Fields§

§manager: Arc<SubscriptionManager>

Subscription manager.

§lifecycle: Arc<dyn SubscriptionLifecycle>

Lifecycle hooks.

§max_subscriptions_per_connection: Option<u32>

Maximum subscriptions per connection (None = unlimited).

§remote_subscription_fields: Arc<HashMap<String, String>>

Subscription fields owned by remote subgraphs.

Maps root subscription field name to the subgraph WebSocket URL. Empty when federation is disabled or no remote subscription fields are declared.

§domain_registry: Option<Arc<DomainRegistry>>

Host-header → tenant-key domain registry. None until a host binary installs one (mirrors AppState::domain_registry).

§strict_tenant_validation: bool

Reject conflicting tenant sources (JWT vs X-Tenant-ID vs Host) on the upgrade. Driven by schema.has_rls_configured(), mirroring the GraphQL handler’s strict tenant validation.

§authorizer: Option<Arc<dyn Authorizer>>

Optional operation-level authorizer (#422). When set, each subscription is authorized at establishment with OperationKind::Subscription, the subscription field name, and the connection’s principal. None until a host binary installs one (from Executor::config().authorizer).

§tenant_status_source: Option<Arc<dyn TenantStatusSource>>

Optional tenant-status source (M-tenant-ws-suspended). When set, a new subscription whose resolved tenant is suspended is rejected, and event delivery to a connection whose tenant is suspended is paused. None until a host binary installs a multi-tenant registry.

Implementations§

Source§

impl SubscriptionState

Source

pub fn new(manager: Arc<SubscriptionManager>) -> Self

Create new subscription state.

Source

pub fn with_tenant_status_source( self, source: Option<Arc<dyn TenantStatusSource>>, ) -> Self

Install the tenant-status source (M-tenant-ws-suspended). When set, new subscriptions for a suspended tenant are rejected and event delivery to a suspended tenant is paused. Typically the TenantExecutorRegistry.

Source

pub fn with_authorizer(self, authorizer: Option<Arc<dyn Authorizer>>) -> Self

Install the operation-level authorizer (#422). When set, every subscription is authorized at establishment; a Deny (or any policy error) rejects the subscription with a FORBIDDEN GraphQL-WS error. Typically populated from Executor::config().authorizer.

Source

pub fn with_tenant_context( self, domain_registry: Arc<DomainRegistry>, strict_tenant_validation: bool, ) -> Self

Install the tenant-resolution context — the Host-header domain registry and strict-validation flag — so the subscription upgrade dispatches the tenant key the same way the GraphQL handler does (JWT tenant_id > X-Tenant-ID header > Host domain, with cross-source conflict rejection when strict_tenant_validation is set). See crate::routes::graphql::TenantKeyResolver.

Source

pub fn with_lifecycle(self, lifecycle: Arc<dyn SubscriptionLifecycle>) -> Self

Set lifecycle hooks.

Source

pub const fn with_max_subscriptions(self, max: Option<u32>) -> Self

Set maximum subscriptions per connection.

Source

pub fn with_remote_subscription_fields( self, fields: HashMap<String, String>, ) -> Self

Set remote subscription fields (federation passthrough).

Maps subscription field names to the owning subgraph’s WebSocket URL.

Trait Implementations§

Source§

impl Clone for SubscriptionState

Source§

fn clone(&self) -> SubscriptionState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more