honker 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +193 -2
- data/ext/honker/extconf.rb +69 -0
- data/ext/honker/honker-core/Cargo.toml +49 -0
- data/ext/honker/honker-core/LICENSE +6 -0
- data/ext/honker/honker-core/LICENSE-APACHE +176 -0
- data/ext/honker/honker-core/LICENSE-MIT +21 -0
- data/ext/honker/honker-core/README.md +30 -0
- data/ext/honker/honker-core/src/cron.rs +473 -0
- data/ext/honker/honker-core/src/honker_ops.rs +1518 -0
- data/ext/honker/honker-core/src/kernel_watcher.rs +434 -0
- data/ext/honker/honker-core/src/lib.rs +3116 -0
- data/ext/honker/honker-core/src/shm_watcher.rs +250 -0
- data/ext/honker/honker-extension/Cargo.toml +36 -0
- data/ext/honker/honker-extension/LICENSE +6 -0
- data/ext/honker/honker-extension/LICENSE-APACHE +176 -0
- data/ext/honker/honker-extension/LICENSE-MIT +21 -0
- data/ext/honker/honker-extension/README.md +41 -0
- data/ext/honker/honker-extension/src/lib.rs +330 -0
- data/honker.gemspec +24 -1
- data/lib/honker/README.md +28 -0
- data/lib/honker/railtie.rb +11 -0
- data/lib/honker/scheduler.rb +59 -0
- data/lib/honker/version.rb +1 -1
- data/lib/honker.rb +111 -3
- metadata +39 -8
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
//! Optional `-shm` fast path (feature = `shm-fast-path`).
|
|
2
|
+
//!
|
|
3
|
+
//! **Experimental.** Weaker correctness contract than the polling
|
|
4
|
+
//! backend, in exchange for sub-millisecond wake latency.
|
|
5
|
+
//!
|
|
6
|
+
//! # Contract
|
|
7
|
+
//!
|
|
8
|
+
//! `on_change()` fires when the `iChange` counter at byte offset 8 of
|
|
9
|
+
//! the WAL index header (`-shm` file) advances. **There is no `PRAGMA
|
|
10
|
+
//! data_version` verification, no safety-net poll, no inode re-mmap.**
|
|
11
|
+
//! This means:
|
|
12
|
+
//!
|
|
13
|
+
//! - **WAL mode required.** No `-shm` exists in DELETE/TRUNCATE/
|
|
14
|
+
//! PERSIST modes. If the file isn't present at startup the backend
|
|
15
|
+
//! logs to stderr and exits — no wakes ever fire.
|
|
16
|
+
//!
|
|
17
|
+
//! - **Trusts the on-disk shm layout.** Reads `iChange` at a fixed
|
|
18
|
+
//! offset and assumes it tracks `PRAGMA data_version`. Verified by
|
|
19
|
+
//! the equivalence test (`shm_fast_path_equivalence_with_pragma_baseline`)
|
|
20
|
+
//! on every supported SQLite version. If a future SQLite version
|
|
21
|
+
//! changes the layout, this breaks silently.
|
|
22
|
+
//!
|
|
23
|
+
//! - **WAL reset / db replacement: watcher death.** If `-shm` or the db
|
|
24
|
+
//! file is deleted and recreated mid-flight (cross-process close+reopen,
|
|
25
|
+
//! atomic rename, litestream restore), the watcher panics with a
|
|
26
|
+
//! "Restart required" message. Same dead-man's-switch shape as the
|
|
27
|
+
//! polling backend — louder failure than silent missed wakes. The file
|
|
28
|
+
//! is read with bounded positional reads instead of mmap so SQLite file
|
|
29
|
+
//! churn cannot SIGBUS the host process.
|
|
30
|
+
//!
|
|
31
|
+
//! Tests assert that wakes fire with sub-millisecond latency in WAL
|
|
32
|
+
//! mode. If a test fails, the backend is broken — not "fall back to
|
|
33
|
+
//! polling and pretend it worked".
|
|
34
|
+
|
|
35
|
+
use crate::stat_identity;
|
|
36
|
+
use rusqlite::{Connection, OpenFlags};
|
|
37
|
+
use std::fs::File;
|
|
38
|
+
use std::io::{Read, Seek, SeekFrom};
|
|
39
|
+
use std::path::PathBuf;
|
|
40
|
+
use std::sync::Arc;
|
|
41
|
+
use std::sync::atomic::{AtomicBool, Ordering};
|
|
42
|
+
use std::time::{Duration, Instant};
|
|
43
|
+
|
|
44
|
+
const WALINDEX_MAX_VERSION: u32 = 3_007_000;
|
|
45
|
+
const ICHANGE_OFFSET: usize = 8;
|
|
46
|
+
/// Same cadence as the polling backend. Shm reads are nearly free; the
|
|
47
|
+
/// win over polling is "PRAGMA -> memory load" (~3.5 us -> ns), not
|
|
48
|
+
/// "1 ms -> 100 us". Going faster would just burn extra sleep syscalls
|
|
49
|
+
/// for latency nobody can perceive.
|
|
50
|
+
const POLL_INTERVAL_MS: u64 = 1;
|
|
51
|
+
/// Cadence for the dead-man's switch (db / -shm replacement detection).
|
|
52
|
+
/// Same wall-clock interval as the polling and kernel backends. Tracked
|
|
53
|
+
/// via Instant — tick counting drifts on Windows where 1 ms sleeps round
|
|
54
|
+
/// up to ~15 ms.
|
|
55
|
+
const IDENTITY_CHECK_INTERVAL: Duration = Duration::from_millis(100);
|
|
56
|
+
|
|
57
|
+
pub(crate) fn run_shm_fast_path_loop<F>(
|
|
58
|
+
db_path: PathBuf,
|
|
59
|
+
on_change: F,
|
|
60
|
+
stop: Arc<AtomicBool>,
|
|
61
|
+
ready: std::sync::mpsc::SyncSender<()>,
|
|
62
|
+
) where
|
|
63
|
+
F: Fn() + Send + 'static,
|
|
64
|
+
{
|
|
65
|
+
if cfg!(target_endian = "big") {
|
|
66
|
+
eprintln!("honker: shm-fast-path requires little-endian platform. Backend disabled.");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let shm_path = PathBuf::from(format!("{}-shm", db_path.display()));
|
|
70
|
+
// Keep a quiet SQLite read connection open for the lifetime of the
|
|
71
|
+
// watcher so normal cross-process open/close churn does not reap or
|
|
72
|
+
// truncate the WAL-index file underneath the fast path. Do not apply
|
|
73
|
+
// the default PRAGMAs here: the application connection already set
|
|
74
|
+
// WAL mode before the watcher is opened, and this connection should
|
|
75
|
+
// not participate in journal-mode setup or checkpoints.
|
|
76
|
+
let _keeper = match Connection::open_with_flags(
|
|
77
|
+
&db_path,
|
|
78
|
+
OpenFlags::SQLITE_OPEN_READ_ONLY | OpenFlags::SQLITE_OPEN_NO_MUTEX,
|
|
79
|
+
) {
|
|
80
|
+
Ok(conn) => Some(conn),
|
|
81
|
+
Err(e) => {
|
|
82
|
+
eprintln!("honker: shm-fast-path keeper connection failed: {e}");
|
|
83
|
+
None
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
let (mut f, header, mut initial_shm_id) = match wait_for_initial_shm_header(&shm_path, &stop) {
|
|
87
|
+
Some(parts) => parts,
|
|
88
|
+
None => {
|
|
89
|
+
let _ = ready.send(());
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
// Sanity: WAL index version we know how to read. A future SQLite
|
|
94
|
+
// that bumps this fails the check instead of reading garbage.
|
|
95
|
+
let iversion = u32::from_ne_bytes(header[0..4].try_into().unwrap());
|
|
96
|
+
if iversion != WALINDEX_MAX_VERSION {
|
|
97
|
+
eprintln!(
|
|
98
|
+
"honker: shm-fast-path disabled: WAL index version {iversion} != {WALINDEX_MAX_VERSION}."
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let mut last = read_ichange_from_header(&header);
|
|
104
|
+
|
|
105
|
+
// Dead-man's switch: snapshot db + -shm inodes; panic on change.
|
|
106
|
+
// Without this the mmap silently sits on a dead -shm inode.
|
|
107
|
+
let initial_db_id = match stat_identity(&db_path) {
|
|
108
|
+
Ok(id) => id,
|
|
109
|
+
Err(e) => {
|
|
110
|
+
eprintln!("honker: failed to stat database for identity check: {e}");
|
|
111
|
+
(0, 0)
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
let mut next_identity_check = Instant::now() + IDENTITY_CHECK_INTERVAL;
|
|
115
|
+
// Baseline captured; signal the spawner that it's safe to return.
|
|
116
|
+
let _ = ready.send(());
|
|
117
|
+
drop(ready);
|
|
118
|
+
|
|
119
|
+
while !stop.load(Ordering::Acquire) {
|
|
120
|
+
std::thread::sleep(Duration::from_millis(POLL_INTERVAL_MS));
|
|
121
|
+
let current = match read_wal_index_header(&mut f) {
|
|
122
|
+
Ok(header) => read_ichange_from_header(&header),
|
|
123
|
+
Err(e) => {
|
|
124
|
+
if let Some((new_file, new_header, new_id)) = reopen_shm_header(&shm_path) {
|
|
125
|
+
f = new_file;
|
|
126
|
+
initial_shm_id = new_id;
|
|
127
|
+
last = read_ichange_from_header(&new_header);
|
|
128
|
+
on_change();
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
eprintln!("honker: shm-fast-path read failed: {e}");
|
|
132
|
+
on_change();
|
|
133
|
+
std::thread::sleep(Duration::from_millis(10));
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if current != last {
|
|
138
|
+
last = current;
|
|
139
|
+
on_change();
|
|
140
|
+
}
|
|
141
|
+
let now = Instant::now();
|
|
142
|
+
if now >= next_identity_check {
|
|
143
|
+
next_identity_check = now + IDENTITY_CHECK_INTERVAL;
|
|
144
|
+
let db_stat_err = check_db_identity(&db_path, initial_db_id);
|
|
145
|
+
match stat_identity(&shm_path) {
|
|
146
|
+
Ok(current_id) if current_id != initial_shm_id => {
|
|
147
|
+
if let Some((new_file, new_header, new_id)) = reopen_shm_header(&shm_path) {
|
|
148
|
+
f = new_file;
|
|
149
|
+
initial_shm_id = new_id;
|
|
150
|
+
last = read_ichange_from_header(&new_header);
|
|
151
|
+
}
|
|
152
|
+
on_change();
|
|
153
|
+
}
|
|
154
|
+
Ok(_) => {}
|
|
155
|
+
Err(e) => {
|
|
156
|
+
eprintln!("honker: stat identity check failed for -shm file: {e}");
|
|
157
|
+
on_change();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if db_stat_err {
|
|
161
|
+
on_change();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fn read_wal_index_header(file: &mut File) -> std::io::Result<[u8; 12]> {
|
|
168
|
+
let mut header = [0_u8; 12];
|
|
169
|
+
file.seek(SeekFrom::Start(0))?;
|
|
170
|
+
file.read_exact(&mut header)?;
|
|
171
|
+
Ok(header)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
fn read_ichange_from_header(header: &[u8; 12]) -> u32 {
|
|
175
|
+
u32::from_ne_bytes(
|
|
176
|
+
header[ICHANGE_OFFSET..ICHANGE_OFFSET + 4]
|
|
177
|
+
.try_into()
|
|
178
|
+
.unwrap(),
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fn reopen_shm_header(path: &std::path::Path) -> Option<(File, [u8; 12], (u64, u64))> {
|
|
183
|
+
let mut file = File::open(path).ok()?;
|
|
184
|
+
let header = read_wal_index_header(&mut file).ok()?;
|
|
185
|
+
let id = stat_identity(path).ok()?;
|
|
186
|
+
Some((file, header, id))
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
fn wait_for_initial_shm_header(
|
|
190
|
+
path: &std::path::Path,
|
|
191
|
+
stop: &AtomicBool,
|
|
192
|
+
) -> Option<(File, [u8; 12], (u64, u64))> {
|
|
193
|
+
for _ in 0..200 {
|
|
194
|
+
if stop.load(Ordering::Acquire) {
|
|
195
|
+
return None;
|
|
196
|
+
}
|
|
197
|
+
if let Some(parts) = reopen_shm_header(path) {
|
|
198
|
+
return Some(parts);
|
|
199
|
+
}
|
|
200
|
+
std::thread::sleep(Duration::from_millis(10));
|
|
201
|
+
}
|
|
202
|
+
eprintln!("honker: shm-fast-path disabled: failed to read stable -shm header.");
|
|
203
|
+
None
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/// Panics if the database has been replaced since startup. Returns
|
|
207
|
+
/// `true` on stat error so caller can fire a conservative wake. The
|
|
208
|
+
/// `-shm` file is intentionally not fatal: SQLite can truncate/recreate
|
|
209
|
+
/// it during normal WAL lifecycle churn, and the fast path can recover
|
|
210
|
+
/// by reopening the current file and rebasing `iChange`.
|
|
211
|
+
fn check_db_identity(db_path: &std::path::Path, initial: (u64, u64)) -> bool {
|
|
212
|
+
match stat_identity(db_path) {
|
|
213
|
+
Ok(current) => {
|
|
214
|
+
if current != initial {
|
|
215
|
+
panic!(
|
|
216
|
+
"honker: database file replaced: \
|
|
217
|
+
expected (dev={}, ino={}), found (dev={}, ino={}) at {:?}. \
|
|
218
|
+
The watcher cannot recover; \
|
|
219
|
+
close the Database and reopen with honker.open().",
|
|
220
|
+
initial.0, initial.1, current.0, current.1, db_path
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
false
|
|
224
|
+
}
|
|
225
|
+
Err(e) => {
|
|
226
|
+
eprintln!("honker: stat identity check failed for database file: {e}");
|
|
227
|
+
true
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// Probe at `honker.open()` so a misconfigured backend errors
|
|
233
|
+
/// immediately instead of silently producing no wakes.
|
|
234
|
+
pub(crate) fn probe(db_path: &std::path::Path) -> Result<(), String> {
|
|
235
|
+
if cfg!(target_endian = "big") {
|
|
236
|
+
return Err("shm-fast-path requires little-endian platform".into());
|
|
237
|
+
}
|
|
238
|
+
let shm = format!("{}-shm", db_path.display());
|
|
239
|
+
let mut f = File::open(&shm)
|
|
240
|
+
.map_err(|e| format!("-shm unavailable ({e}). WAL mode + open connection required."))?;
|
|
241
|
+
let header =
|
|
242
|
+
read_wal_index_header(&mut f).map_err(|e| format!("-shm too small or unreadable: {e}"))?;
|
|
243
|
+
let iv = u32::from_ne_bytes(header[0..4].try_into().unwrap());
|
|
244
|
+
if iv != WALINDEX_MAX_VERSION {
|
|
245
|
+
return Err(format!(
|
|
246
|
+
"WAL index version {iv} != {WALINDEX_MAX_VERSION} (unsupported SQLite layout)"
|
|
247
|
+
));
|
|
248
|
+
}
|
|
249
|
+
Ok(())
|
|
250
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "honker-extension"
|
|
3
|
+
version = "0.2.3"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
description = "SQLite loadable extension for Honker. Adds honker_* SQL functions (queues, streams, scheduler, pub/sub) to any SQLite client."
|
|
6
|
+
license = "MIT OR Apache-2.0"
|
|
7
|
+
repository = "https://github.com/russellromney/honker"
|
|
8
|
+
homepage = "https://honker.dev"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["sqlite", "queue", "pubsub", "notify", "honker"]
|
|
11
|
+
categories = ["database", "concurrency"]
|
|
12
|
+
|
|
13
|
+
# Output file is `libhonker_ext.dylib` / `.so`. Users load with:
|
|
14
|
+
# SELECT load_extension('/path/to/libhonker_ext');
|
|
15
|
+
# The crate name differs from the PyO3 `honker` cdylib because both
|
|
16
|
+
# would otherwise try to write `target/release/libhonker.dylib` and
|
|
17
|
+
# clobber each other.
|
|
18
|
+
[lib]
|
|
19
|
+
name = "honker_ext"
|
|
20
|
+
crate-type = ["cdylib"]
|
|
21
|
+
|
|
22
|
+
[dependencies]
|
|
23
|
+
# Using both `path` and `version` lets Cargo publish this crate to
|
|
24
|
+
# crates.io referencing the real honker-core = "0.2" while still
|
|
25
|
+
# using the in-tree source for local builds.
|
|
26
|
+
honker-core = { path = "../honker-core", version = "0.2.3", default-features = false }
|
|
27
|
+
# "loadable_extension" feature makes rusqlite usable from inside a
|
|
28
|
+
# sqlite3_extension_init entry point.
|
|
29
|
+
rusqlite = { version = "0.39.0", features = ["functions", "hooks", "loadable_extension"] }
|
|
30
|
+
|
|
31
|
+
[features]
|
|
32
|
+
default = []
|
|
33
|
+
kernel-watcher = ["honker-core/kernel-watcher"]
|
|
34
|
+
shm-fast-path = ["honker-core/shm-fast-path"]
|
|
35
|
+
|
|
36
|
+
[workspace]
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Russell Romney
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# honker-extension
|
|
2
|
+
|
|
3
|
+
SQLite loadable extension for [Honker](https://honker.dev). Adds every `honker_*` SQL scalar function (queues, streams, scheduler, pub/sub, rate limits, locks, results) to any SQLite 3.9+ client.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
From crates.io (builds `libhonker_ext.dylib` / `.so` for your platform):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
cargo install honker-extension
|
|
11
|
+
# or build from source:
|
|
12
|
+
cargo build --release -p honker-extension
|
|
13
|
+
# → target/release/libhonker_ext.{dylib,so}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Prebuilt binaries per platform are available at [GitHub releases](https://github.com/russellromney/honker/releases/latest).
|
|
17
|
+
|
|
18
|
+
## Use
|
|
19
|
+
|
|
20
|
+
```sql
|
|
21
|
+
.load ./libhonker_ext
|
|
22
|
+
SELECT honker_bootstrap();
|
|
23
|
+
|
|
24
|
+
-- Queues
|
|
25
|
+
SELECT honker_enqueue('emails', '{"to":"alice"}', NULL, NULL, 0, 3, NULL);
|
|
26
|
+
SELECT honker_claim_batch('emails', 'worker-1', 32, 300);
|
|
27
|
+
SELECT honker_ack_batch('[1,2,3]', 'worker-1');
|
|
28
|
+
|
|
29
|
+
-- Streams (durable pub/sub)
|
|
30
|
+
SELECT honker_stream_publish('orders', 'k', '{"id":42}');
|
|
31
|
+
SELECT honker_stream_read_since('orders', 0, 1000);
|
|
32
|
+
|
|
33
|
+
-- pg_notify-style pub/sub
|
|
34
|
+
SELECT notify('orders', '{"id":42}');
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Full SQL reference: [honker.dev/reference/extension](https://honker.dev/reference/extension/).
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
Apache-2.0.
|