pub struct ActiveSubscription {
pub id: SubscriptionId,
pub subscription_name: String,
pub definition: SubscriptionDefinition,
pub user_context: Value,
pub variables: Value,
pub created_at: DateTime<Utc>,
pub connection_id: String,
pub rls_conditions: Vec<(String, Value)>,
pub tenant_id: Option<String>,
pub plan: Option<Arc<SubscriptionPlan>>,
pub delivered: Arc<AtomicU64>,
}Expand description
A client’s active subscription.
Fields§
§id: SubscriptionIdUnique subscription ID.
subscription_name: StringSubscription type name from schema.
definition: SubscriptionDefinitionReference to subscription definition.
user_context: ValueUser context for authorization filtering.
variables: ValueRuntime variables provided by client.
created_at: DateTime<Utc>When the subscription was created.
connection_id: StringConnection/client identifier (for routing).
rls_conditions: Vec<(String, Value)>Row-level security conditions evaluated at subscribe time.
Each entry is (field_path, expected_value). An event is only delivered
when every condition matches the event data (AND semantics).
An empty list means no RLS filtering (admin or no RLS policy).
tenant_id: Option<String>Tenant identifier for multi-tenant isolation.
When set, only events with a matching tenant_id are delivered.
Extracted from the subscriber’s JWT fk_customer_org claim at subscribe time.
plan: Option<Arc<SubscriptionPlan>>What each event is served as for this subscriber (ruling AA 4): planned by the
executor at subscribe time from the client’s selection and principal. None for a
subscription registered without one.
delivered: Arc<AtomicU64>Events delivered to this subscription so far (ruling AA 5): the next delivery’s position is one more. Shared by clones, so it counts each delivery once.
Implementations§
Source§impl ActiveSubscription
impl ActiveSubscription
Sourcepub fn new(
subscription_name: impl Into<String>,
definition: SubscriptionDefinition,
user_context: Value,
variables: Value,
connection_id: impl Into<String>,
) -> Self
pub fn new( subscription_name: impl Into<String>, definition: SubscriptionDefinition, user_context: Value, variables: Value, connection_id: impl Into<String>, ) -> Self
Create a new active subscription.
§Arguments
subscription_name- Schema subscription namedefinition- Subscription definition from compiled schemauser_context- Raw user context JSON fromWebSocketconnection_initvariables- Runtime variables from clientconnection_id- Client connection identifier
Sourcepub fn with_rls_conditions(self, conditions: Vec<(String, Value)>) -> Self
pub fn with_rls_conditions(self, conditions: Vec<(String, Value)>) -> Self
Set row-level security conditions for event filtering.
The caller evaluates the RLS policy against the user’s SecurityContext
at subscribe time and converts the resulting WhereClause into
(field, value) equality conditions. During event delivery,
matches_subscription checks every condition against the event data.
Sourcepub fn with_plan(self, plan: Arc<SubscriptionPlan>) -> Self
pub fn with_plan(self, plan: Arc<SubscriptionPlan>) -> Self
Serve every event through plan (ruling AA 4).