Struct SubscriptionManager

Source
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

Source

pub fn for_test_without_metrics_arc_rwlock() -> Arc<RwLock<Self>>

Source

pub fn for_test_without_metrics() -> Self

Source

pub fn new(send_worker_queue: BroadcastQueue) -> Self

Source

pub fn query(&self, hash: &QueryHash) -> Option<Arc<Plan>>

Source

pub fn calculate_gauge_stats(&self) -> SubscriptionGaugeStats

Source

pub fn num_unique_queries(&self) -> usize

Source

pub fn remove_dropped_clients(&mut self)

Remove any clients that have been marked for removal

Source

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.

Source

pub fn add_subscription( &mut self, client: Arc<ClientConnectionSender>, query: Arc<Plan>, query_id: QueryId, ) -> Result<(), DBError>

Adds a single subscription for a client.

Source

pub fn add_subscription_multi( &mut self, client: Arc<ClientConnectionSender>, queries: Vec<Arc<Plan>>, query_id: QueryId, ) -> Result<Vec<Arc<Plan>>, DBError>

Source

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.

Source

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.

Source

pub fn index_ids_for_subscriptions(&self) -> &QueriedTableIndexIds

Returns the index ids that are used in subscription queries

Source

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§

Source§

impl Debug for SubscriptionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T