reifydb_subscription/delivery.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use reifydb_core::{interface::catalog::id::SubscriptionId, value::column::columns::Columns};
5
6/// Result of attempting to deliver a subscription frame.
7#[derive(Debug)]
8pub enum DeliveryResult {
9 /// Frame was successfully delivered.
10 Delivered,
11 /// Consumer is not ready (e.g., channel full). Retry later.
12 BackPressure,
13 /// Consumer has disconnected. Subscription should be cleaned up.
14 Disconnected,
15}
16
17/// Trait for delivering subscription data to consumers.
18///
19/// Implementations handle the protocol-specific details of sending
20/// subscription frames to clients.
21pub trait SubscriptionDelivery: Send + Sync {
22 /// Try to deliver columns to the subscription's consumer.
23 fn try_deliver(&self, subscription: &SubscriptionId, columns: Columns) -> DeliveryResult;
24
25 /// Get the list of currently active subscription IDs.
26 fn active_subscriptions(&self) -> Vec<SubscriptionId>;
27}