Skip to main content

uqa_storage/notifications/
registry.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Provider-neutral committed queue and listener records.
8
9#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
10pub struct NotificationQueueState {
11    pub next_sequence: u64,
12    pub head_position: u64,
13}
14
15#[derive(Clone, Debug, PartialEq, Eq)]
16pub struct NotificationQueueEntry {
17    pub sequence: u64,
18    pub process_id: i32,
19    pub channel: String,
20    pub payload: String,
21}
22
23/// One registry row borrowed until the visitor returns; no channel or payload allocation is transferred implicitly.
24#[derive(Clone, Copy, PartialEq, Eq)]
25pub struct NotificationQueueEntryRef<'a> {
26    pub sequence: u64,
27    pub process_id: i32,
28    pub channel: &'a str,
29    pub payload: &'a str,
30}
31
32/// Progress over accepted rows in a finite registry visit. An inspected but declined row remains at the resume boundary.
33#[derive(Clone, Copy, Debug, PartialEq, Eq)]
34pub struct NotificationQueueScan {
35    pub visited: usize,
36    pub next_sequence: u64,
37    /// True only when the query actually observed its end; reaching a row limit does not prove exhaustion.
38    pub exhausted: bool,
39}
40
41#[derive(Clone, Debug, PartialEq, Eq)]
42pub struct NotificationListenerRow {
43    pub owner_id: [u8; 16],
44    pub session_id: u64,
45    pub process_id: i32,
46    pub wake_port: u16,
47    pub channels: Vec<String>,
48    pub transaction_open: bool,
49    pub next_sequence: u64,
50    pub position: u64,
51}
52
53/// Stable lexicographic registry key; the session identifier is stored big-endian.
54#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
55pub struct NotificationListenerKey {
56    pub owner_id: [u8; 16],
57    pub session_id: u64,
58}
59
60/// Fixed-width coordination metadata, independent of a listener's channel list.
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub struct NotificationListenerMetadata {
63    pub key: NotificationListenerKey,
64    pub process_id: i32,
65    pub wake_port: u16,
66    pub transaction_open: bool,
67    pub next_sequence: u64,
68    pub position: u64,
69}