SQLite engine: notify/listen — auto-commit notify, watcher-fanout WakeReceiver bridge (task sqlite-engine-notify-listen)

This commit is contained in:
glm-5.3-flash committed 2026-10-08 12:12:34 +00:00
1 parent c38033db1a
commit 8efe0c2e78
7 files changed
+795 -24

No files matched your search

+14 -13
View File
@@ -34,6 +34,7 @@
use alkstore::Store;
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use crate::opts::SqliteOpts;
use crate::seam::{database_error, sqlite_error};
@@ -48,6 +49,7 @@ pub struct SqliteStore {
readers: Arc<Readers>,
watcher: Arc<SharedUpdateWatcher>,
db_path: PathBuf,
closed: Arc<AtomicBool>,
}
impl std::fmt::Debug for SqliteStore {
@@ -64,6 +66,7 @@ impl SqliteStore {
/// reader pool, and closes the writer slot. Idempotent. [`Drop`]
/// delegates here.
pub fn close(&self) {
self.closed.store(true, std::sync::atomic::Ordering::SeqCst);
let _ = self.watcher.close();
self.readers.close();
self.writer.close();
@@ -105,6 +108,7 @@ fn open_store(path: &str, opts: SqliteOpts) -> alkstore::Result<SqliteStore> {
readers: Arc::new(Readers::new(path.to_string(), opts.max_readers)),
watcher: Arc::new(watcher),
db_path: PathBuf::from(path),
closed: Arc::new(AtomicBool::new(false)),
})
}
@@ -122,25 +126,20 @@ impl Store for SqliteStore {
fn notify<'a>(
&'a self,
_channel: &str,
_payload: serde_json::Value,
channel: &str,
payload: serde_json::Value,
) -> alkstore::BoxedFuture<'a, alkstore::Result<()>> {
Box::pin(async {
Err(database_error(
"notify wiring lands with the mechanism tasks",
))
})
crate::notify::notify(self.writer.clone(), channel, payload)
}
fn listen<'a>(
&'a self,
_channel: &str,
channel: &str,
) -> alkstore::BoxedFuture<'a, alkstore::Result<Box<dyn alkstore::WakeReceiver>>> {
Box::pin(async {
Err(database_error(
"listen wiring lands with the mechanism tasks",
))
})
let watcher = self.watcher.clone();
let closed = self.closed.clone();
let channel = channel.to_string();
Box::pin(async move { crate::notify::listen(watcher, closed, &channel) })
}
fn stream<'a>(
@@ -221,6 +220,8 @@ impl Store for SqliteStore {
}
}
#[cfg(test)]
mod notify_tests;
#[cfg(test)]
mod open_tests;
#[cfg(test)]