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: boolReject 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.
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
impl SubscriptionState
Sourcepub fn new(manager: Arc<SubscriptionManager>) -> Self
pub fn new(manager: Arc<SubscriptionManager>) -> Self
Create new subscription state.
Sourcepub fn with_tenant_status_source(
self,
source: Option<Arc<dyn TenantStatusSource>>,
) -> Self
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.
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.
Sourcepub fn with_tenant_context(
self,
domain_registry: Arc<DomainRegistry>,
strict_tenant_validation: bool,
) -> Self
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.
Sourcepub fn with_lifecycle(self, lifecycle: Arc<dyn SubscriptionLifecycle>) -> Self
pub fn with_lifecycle(self, lifecycle: Arc<dyn SubscriptionLifecycle>) -> Self
Set lifecycle hooks.
Sourcepub const fn with_max_subscriptions(self, max: Option<u32>) -> Self
pub const fn with_max_subscriptions(self, max: Option<u32>) -> Self
Set maximum subscriptions per connection.
Sourcepub fn with_remote_subscription_fields(
self,
fields: HashMap<String, String>,
) -> Self
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
impl Clone for SubscriptionState
Source§fn clone(&self) -> SubscriptionState
fn clone(&self) -> SubscriptionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SubscriptionState
impl !UnwindSafe for SubscriptionState
impl Freeze for SubscriptionState
impl Send for SubscriptionState
impl Sync for SubscriptionState
impl Unpin for SubscriptionState
impl UnsafeUnpin for SubscriptionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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