pub struct SubscriptionManager { /* private fields */ }Expand description
Group-based subscription manager using sharded concurrent data structures.
Primary index: groups by QueryGroupId (DashMap, 64 shards). Secondary: lookup key -> QueryGroupId for dedup. Subscribers stored in a HashMap for O(1) insert/remove by key. Session -> subscribers mapping for cleanup.
Implementations§
Source§impl SubscriptionManager
impl SubscriptionManager
Sourcepub fn subscribe(
&self,
session_id: SessionId,
client_sub_id: String,
query_name: &str,
args: &Value,
auth_context: &AuthContext,
table_deps: &'static [&'static str],
selected_cols: &'static [&'static str],
) -> Result<(QueryGroupId, SubscriptionId, bool)>
pub fn subscribe( &self, session_id: SessionId, client_sub_id: String, query_name: &str, args: &Value, auth_context: &AuthContext, table_deps: &'static [&'static str], selected_cols: &'static [&'static str], ) -> Result<(QueryGroupId, SubscriptionId, bool)>
Subscribe to a query group. Returns the group ID and whether this is a new group. If a group already exists for this query+args+auth_scope, the subscriber joins it.
Sourcepub fn unsubscribe(&self, subscription_id: SubscriptionId)
pub fn unsubscribe(&self, subscription_id: SubscriptionId)
Remove a subscriber by its subscription ID.
Sourcepub fn remove_session_subscriptions(
&self,
session_id: SessionId,
) -> Vec<SubscriptionId>
pub fn remove_session_subscriptions( &self, session_id: SessionId, ) -> Vec<SubscriptionId>
Remove all subscriptions for a session.
Sourcepub fn find_affected_groups(&self, change: &Change) -> Vec<QueryGroupId>
pub fn find_affected_groups(&self, change: &Change) -> Vec<QueryGroupId>
Find all groups affected by a change. Returns group IDs (not subscription IDs). This is O(groups_for_table), not O(all_subscriptions).
Sourcepub fn get_group(
&self,
group_id: QueryGroupId,
) -> Option<Ref<'_, QueryGroupId, QueryGroup>>
pub fn get_group( &self, group_id: QueryGroupId, ) -> Option<Ref<'_, QueryGroupId, QueryGroup>>
Get a reference to a group by ID.
Sourcepub fn get_group_mut(
&self,
group_id: QueryGroupId,
) -> Option<RefMut<'_, QueryGroupId, QueryGroup>>
pub fn get_group_mut( &self, group_id: QueryGroupId, ) -> Option<RefMut<'_, QueryGroupId, QueryGroup>>
Get a mutable reference to a group by ID.
Sourcepub fn get_group_subscribers(
&self,
group_id: QueryGroupId,
) -> Vec<(SessionId, String)>
pub fn get_group_subscribers( &self, group_id: QueryGroupId, ) -> Vec<(SessionId, String)>
Get all subscriber info for a group (for fan-out).
Sourcepub fn update_group(
&self,
group_id: QueryGroupId,
read_set: ReadSet,
result_hash: String,
)
pub fn update_group( &self, group_id: QueryGroupId, read_set: ReadSet, result_hash: String, )
Update a group after re-execution.
Sourcepub fn group_count(&self) -> usize
pub fn group_count(&self) -> usize
Get group count.
Auto Trait Implementations§
impl !Freeze for SubscriptionManager
impl !RefUnwindSafe for SubscriptionManager
impl Send for SubscriptionManager
impl Sync for SubscriptionManager
impl Unpin for SubscriptionManager
impl UnsafeUnpin for SubscriptionManager
impl UnwindSafe for SubscriptionManager
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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