1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! LiveQueryService process-static configuration — named consts and env knobs
//! resolved exactly once (never per-subscribe).
use OnceLock;
/// Service id this handler dispatches its mediated snapshot reads under. The
/// dispatch target only selects the backend/instance; the table is resolved from
/// the request `message_type` via the embedded manifest, so a snapshot reads the
/// source entity's table on the resolved (postgres) store.
pub const SERVICE_ID: &str = "livequery";
/// Default bound on the initial snapshot row count when the caller omits one.
pub const DEFAULT_SNAPSHOT_LIMIT: u32 = 1_000;
/// Hard cap on the initial snapshot so one subscription cannot scan unbounded.
pub const MAX_SNAPSHOT_LIMIT: u32 = 10_000;
/// Default bounded per-subscription delta buffer. Overridable via
/// `LIVEQUERY_BUFFER_EVENTS`; on overflow the stream is closed (never grown).
const DEFAULT_BUFFER_EVENTS: usize = 1_024;
/// Resolve the bounded delta-buffer depth from `LIVEQUERY_BUFFER_EVENTS`,
/// falling back to [`DEFAULT_BUFFER_EVENTS`]. A non-positive / unparsable value
/// uses the default so the channel is always bounded. Resolved exactly once
/// (no per-subscribe env reads): the buffer bound is process-static config.
pub
/// Default per-tenant budget of CONCURRENT long-lived subscription streams.
/// The fair-admission permit taken at `subscribe` entry only rate-bounds
/// subscription SETUP (it is dropped immediately, by design, so a long-lived
/// stream never pins an admission slot); this budget is what bounds how many
/// open streams one tenant can hold at once.
const DEFAULT_MAX_STREAMS_PER_TENANT: usize = 64;
/// Resolve the per-tenant concurrent-stream budget from
/// `UDB_LIVEQUERY_MAX_STREAMS_PER_TENANT`, falling back to
/// [`DEFAULT_MAX_STREAMS_PER_TENANT`]. A non-positive / unparsable value uses
/// the default so the budget is always finite. Resolved exactly once (no
/// per-subscribe env reads): the budget is process-static config.
pub