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: SubscriptionIdUnique identifier for this subscription
query: StringThe SQL query being monitored
tables: HashSet<String>Tables this query depends on (extracted from AST)
last_result_hash: u64Hash 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: SubscriptionRetryPolicyRetry policy for handling transient errors
retry_count: u32Current retry attempt count (resets on successful execution)
updates_sent: u64Total updates sent to this subscription
updates_dropped: u64Total updates dropped due to channel being full
channel_buffer_size: usizeBuffer size for the subscription channel
slow_consumer_threshold_percent: u8Slow 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: boolWhether 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
impl Subscription
Sourcepub fn new(
query: String,
tables: HashSet<String>,
notify_tx: Sender<SubscriptionUpdate>,
) -> Self
pub fn new( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, ) -> Self
Create a new subscription
Sourcepub fn with_policy(
query: String,
tables: HashSet<String>,
notify_tx: Sender<SubscriptionUpdate>,
retry_policy: SubscriptionRetryPolicy,
) -> Self
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
Sourcepub fn with_config(
query: String,
tables: HashSet<String>,
notify_tx: Sender<SubscriptionUpdate>,
config: &SubscriptionConfig,
) -> Self
pub fn with_config( query: String, tables: HashSet<String>, notify_tx: Sender<SubscriptionUpdate>, config: &SubscriptionConfig, ) -> Self
Create a new subscription with custom configuration
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub fn set_pk_columns(&mut self, pk_columns: Vec<usize>)
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.
Sourcepub fn set_pk_columns_with_eligibility(
&mut self,
pk_columns: Vec<usize>,
confident: bool,
) -> bool
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.
Sourcepub fn set_selective_updates_override(&mut self, config: SelectiveColumnConfig)
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.
Sourcepub fn clear_selective_updates_override(&mut self)
pub fn clear_selective_updates_override(&mut self)
Clear the selective updates override (use server defaults)
Sourcepub fn get_effective_selective_config(
&self,
server_config: &SelectiveColumnConfig,
) -> SelectiveColumnConfig
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§
Auto Trait Implementations§
impl Freeze for Subscription
impl RefUnwindSafe for Subscription
impl Send for Subscription
impl Sync for Subscription
impl Unpin for Subscription
impl UnsafeUnpin for Subscription
impl UnwindSafe for Subscription
Blanket Implementations§
impl<T> Allocation for T
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>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request