Skip to main content

Subscription

Struct Subscription 

Source
pub struct Subscription {
Show 18 fields pub id: SubscriptionId, pub query: String, pub tables: HashSet<String>, pub last_result_hash: u64, pub last_result: Option<Vec<Row>>, pub notify_tx: Sender<SubscriptionUpdate>, pub retry_policy: SubscriptionRetryPolicy, pub retry_count: u32, pub updates_sent: u64, pub updates_dropped: u64, pub channel_buffer_size: usize, pub slow_consumer_threshold_percent: u8, pub connection_id: Option<String>, pub wire_subscription_id: Option<[u8; 16]>, pub filter: Option<String>, pub pk_columns: Vec<usize>, pub selective_eligible: bool, pub selective_updates_override: Option<SelectiveColumnConfig>,
}
Expand description

A single query subscription

Tracks the query, its table dependencies, and the channel for sending updates.

Fields§

§id: SubscriptionId

Unique identifier for this subscription

§query: String

The SQL query being monitored

§tables: HashSet<String>

Tables this query depends on (extracted from AST)

§last_result_hash: u64

Hash of the last result set (for change detection)

§last_result: Option<Vec<Row>>

Last result set (for delta computation) This stores the previous result to enable computing deltas on change.

§notify_tx: Sender<SubscriptionUpdate>

Channel to send updates to the subscriber

§retry_policy: SubscriptionRetryPolicy

Retry policy for handling transient errors

§retry_count: u32

Current retry attempt count (resets on successful execution)

§updates_sent: u64

Total updates sent to this subscription

§updates_dropped: u64

Total updates dropped due to channel being full

§channel_buffer_size: usize

Buffer size for the subscription channel

§slow_consumer_threshold_percent: u8

Slow consumer threshold percentage

§connection_id: Option<String>

Optional connection/session ID that owns this subscription Used for connection-level subscription tracking and cleanup

§wire_subscription_id: Option<[u8; 16]>

Optional wire protocol subscription ID (UUID bytes) Used to bridge between wire protocol IDs and internal SubscriptionId

§filter: Option<String>

Optional filter expression (SQL WHERE clause) to apply to updates Only rows matching the filter will be included in subscription updates

§pk_columns: Vec<usize>

Primary key column indices in the result set Used for selective column updates to always include PK columns Default: [0] (assumes first column is PK if not detected)

§selective_eligible: bool

Whether this subscription is eligible for selective column updates True when PK columns were confidently detected

§selective_updates_override: Option<SelectiveColumnConfig>

Per-subscription override for selective column update configuration If set, this overrides the server-level selective_updates config for this subscription

Implementations§

Source§

impl Subscription

Source

pub fn new( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, ) -> Self

Create a new subscription

Source

pub fn with_policy( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, retry_policy: SubscriptionRetryPolicy, ) -> Self

Create a new subscription with a custom retry policy

Source

pub fn with_config( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, config: &SubscriptionConfig, ) -> Self

Create a new subscription with custom configuration

Source

pub fn for_connection( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, connection_id: String, wire_subscription_id: [u8; 16], filter: Option<String>, config: &SubscriptionConfig, ) -> Self

Create a new subscription for a specific connection (wire protocol)

This associates the subscription with a connection ID for tracking and cleanup when the connection closes.

Source

pub fn for_connection_with_pk( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, connection_id: String, wire_subscription_id: [u8; 16], filter: Option<String>, config: &SubscriptionConfig, pk_columns: Vec<usize>, ) -> Self

Create a new subscription for a specific connection with custom PK columns

This associates the subscription with a connection ID for tracking and cleanup when the connection closes. It also allows specifying which columns are primary keys for selective column updates.

Source

pub fn set_pk_columns(&mut self, pk_columns: Vec<usize>)

Set the primary key columns for this subscription

Used after detection to update the subscription with actual PK columns.

Source

pub fn set_pk_columns_with_eligibility( &mut self, pk_columns: Vec<usize>, confident: bool, ) -> bool

Set both PK columns and selective eligibility

Used after PK detection to update the subscription. Returns true if the subscription is newly marked as selective-eligible.

Source

pub fn set_selective_updates_override(&mut self, config: SelectiveColumnConfig)

Set per-subscription selective updates override

Allows clients to override server-level selective update thresholds on a per-subscription basis.

Source

pub fn clear_selective_updates_override(&mut self)

Clear the selective updates override (use server defaults)

Source

pub fn get_effective_selective_config( &self, server_config: &SelectiveColumnConfig, ) -> SelectiveColumnConfig

Get the effective selective column update config for this subscription

Returns the per-subscription override if set, otherwise creates a config from the server-level config with this subscription’s PK columns.

Trait Implementations§

Source§

impl Debug for Subscription

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> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> MaybeSend for T
where T: Send,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool