pub struct SubscriptionManager { /* private fields */ }Expand description
Responsible for the efficient evaluation of subscriptions. It performs basic multi-query optimization, in that if a query has N subscribers, it is only executed once, with the results copied to the N receivers.
Implementations§
Source§impl SubscriptionManager
impl SubscriptionManager
pub fn for_test_without_metrics_arc_rwlock() -> Arc<RwLock<Self>> ⓘ
pub fn for_test_without_metrics() -> Self
pub fn new(send_worker_queue: BroadcastQueue) -> Self
pub fn query(&self, hash: &QueryHash) -> Option<Arc<Plan>>
pub fn calculate_gauge_stats(&self) -> SubscriptionGaugeStats
pub fn num_unique_queries(&self) -> usize
Sourcepub fn remove_dropped_clients(&mut self)
pub fn remove_dropped_clients(&mut self)
Remove any clients that have been marked for removal
Sourcepub fn remove_subscription(
&mut self,
client_id: (Identity, ConnectionId),
query_id: QueryId,
) -> Result<Vec<Arc<Plan>>, DBError>
pub fn remove_subscription( &mut self, client_id: (Identity, ConnectionId), query_id: QueryId, ) -> Result<Vec<Arc<Plan>>, DBError>
Remove a single subscription for a client. This will return an error if the client does not have a subscription with the given query id.
Sourcepub fn add_subscription(
&mut self,
client: Arc<ClientConnectionSender>,
query: Arc<Plan>,
query_id: QueryId,
) -> Result<(), DBError>
pub fn add_subscription( &mut self, client: Arc<ClientConnectionSender>, query: Arc<Plan>, query_id: QueryId, ) -> Result<(), DBError>
Adds a single subscription for a client.
pub fn add_subscription_multi( &mut self, client: Arc<ClientConnectionSender>, queries: Vec<Arc<Plan>>, query_id: QueryId, ) -> Result<Vec<Arc<Plan>>, DBError>
Sourcepub fn set_legacy_subscription(
&mut self,
client: Arc<ClientConnectionSender>,
queries: impl IntoIterator<Item = Arc<Plan>>,
)
pub fn set_legacy_subscription( &mut self, client: Arc<ClientConnectionSender>, queries: impl IntoIterator<Item = Arc<Plan>>, )
Adds a client and its queries to the subscription manager. Sets up the set of subscriptions for the client, replacing any existing legacy subscriptions.
If a query is not already indexed, its table ids added to the inverted index.
Sourcepub fn remove_all_subscriptions(&mut self, client: &(Identity, ConnectionId))
pub fn remove_all_subscriptions(&mut self, client: &(Identity, ConnectionId))
Removes a client from the subscriber mapping. If a query no longer has any subscribers, it is removed from the index along with its table ids.
Sourcepub fn index_ids_for_subscriptions(&self) -> &QueriedTableIndexIds
pub fn index_ids_for_subscriptions(&self) -> &QueriedTableIndexIds
Returns the index ids that are used in subscription queries
Sourcepub fn eval_updates_sequential(
&self,
tx: &DeltaTx<'_>,
event: Arc<ModuleEvent>,
caller: Option<Arc<ClientConnectionSender>>,
) -> ExecutionMetrics
pub fn eval_updates_sequential( &self, tx: &DeltaTx<'_>, event: Arc<ModuleEvent>, caller: Option<Arc<ClientConnectionSender>>, ) -> ExecutionMetrics
This method takes a set of delta tables, evaluates only the necessary queries for those delta tables, and then sends the results to each client.
This previously used rayon to parallelize subscription evaluation. However, in order to optimize for the common case of small updates, we removed rayon and switched to a single-threaded execution, which removed significant overhead associated with thread switching.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SubscriptionManager
impl RefUnwindSafe for SubscriptionManager
impl Send for SubscriptionManager
impl Sync for SubscriptionManager
impl Unpin 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> 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