Skip to content

Commit dc89f5f

Browse files
authored
feat(events): Database Event Channels extension (#291)
Adds the full SQLSpec Events extension: a unified event channel API with sync/async implementations, durable queue fallback, and native backends where available. This includes adapter-specific event backends, migration support, and framework integration for Litestar channels.
1 parent 47ee1ed commit dc89f5f

File tree

167 files changed

+11747
-864
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+11747
-864
lines changed

.claude/agents/docs-vision.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: docs-vision
33
description: Documentation excellence, quality gate validation, and workspace cleanup specialist - ensures code quality, comprehensive docs, and clean workspace before completion
44
tools: mcp__context7__resolve-library-id, mcp__context7__get-library-docs, WebSearch, Read, Write, Edit, Glob, Grep, Bash, Find, Task
5-
model: sonnet
5+
model: opus
66
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
77
guides_root: ../docs/guides/
88
workspace_root: ../specs/active/

.claude/agents/expert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: expert
33
description: SQLSpec domain expert with comprehensive knowledge of database adapters, SQL parsing, type system, storage backends, and Litestar integration
44
tools: mcp__context7__resolve-library-id, mcp__context7__get-library-docs, WebSearch, mcp__zen__analyze, mcp__zen__thinkdeep, mcp__zen__debug, Read, Write, Edit, Glob, Grep, Bash, Find, Task
5-
model: sonnet
5+
model: opus
66
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
77
guides_root: ../docs/guides/
88
workspace_root: ../specs/active/

.claude/agents/prd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: prd
33
description: Product Requirements and Design agent for complex SQLSpec development spanning multiple files, adapters, and features
44
tools: mcp__zen__planner, mcp__context7__resolve-library-id, mcp__context7__get-library-docs, WebSearch, mcp__zen__consensus, Read, Write, Edit, Glob, Grep, Bash, Find, Task
5-
model: sonnet
5+
model: opus
66
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
77
guides_root: ../docs/guides/
88
workspace_root: ../specs/active/

.claude/agents/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: testing
33
description: Comprehensive testing specialist for SQLSpec - creates unit tests, integration tests, fixtures, and validates test coverage across all database adapters
44
tools: mcp__context7__resolve-library-id, mcp__context7__get-library-docs, Read, Write, Edit, Glob, Grep, Bash, Find, Task
5-
model: sonnet
5+
model: opus
66
standards_uri: ../AGENTS.md#mandatory-code-quality-standards
77
guides_root: ../docs/guides/
88
workspace_root: ../specs/active/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: mixed-line-ending
1818
- id: trailing-whitespace
1919
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: "v0.14.9"
20+
rev: "v0.14.10"
2121
hooks:
2222
- id: ruff
2323
args: ["--fix"]

AGENTS.md

Lines changed: 274 additions & 42 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SQLSpec is currently in active development. The public API may change. Follow th
4242

4343
- SQL validation and caching via sqlglot AST parsing
4444
- OpenTelemetry and Prometheus instrumentation hooks
45+
- Database event channels with native LISTEN/NOTIFY, Oracle AQ, and a portable queue fallback
4546
- Structured logging with correlation ID support
4647
- Migration CLI for schema versioning
4748

docs/PYPI_README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SQLSpec is currently in active development. The public API may change. Follow th
4242

4343
- SQL validation and caching via sqlglot AST parsing
4444
- OpenTelemetry and Prometheus instrumentation hooks
45+
- Database event channels with native LISTEN/NOTIFY, Oracle AQ, and a portable queue fallback
4546
- Structured logging with correlation ID support
4647
- Migration CLI for schema versioning
4748

docs/changelog.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ SQLSpec Changelog
1010
Recent Updates
1111
==============
1212

13+
Database Event Channels
14+
-----------------------
15+
16+
- Added ``sqlspec.extensions.events.EventChannel`` with queue-backed publish/listen APIs that work uniformly across sync and async adapters.
17+
- Exposed ``SQLSpec.event_channel(config)`` so applications and agents can build channels directly from registered configs.
18+
- Introduced the ``events`` extension migrations (``ext_events_0001``) which create the durable queue table plus composite index.
19+
- Added the first native backend (AsyncPG LISTEN/NOTIFY) enabled via ``driver_features["events_backend"] = "listen_notify"``; the API automatically falls back to the queue backend for other adapters.
20+
- Introduced experimental Oracle Advanced Queuing support (sync adapters) via ``driver_features["events_backend"] = "advanced_queue"`` with automatic fallback when AQ is unavailable.
21+
- Documented configuration patterns (queue table naming, lease/retention windows, Oracle ``INMEMORY`` toggle, Postgres native mode) in :doc:`/guides/events/database-event-channels`.
22+
- Event telemetry now tracks ``events.publish``, ``events.publish.native``, ``events.deliver``, ``events.ack``, ``events.nack``, ``events.shutdown`` and listener lifecycle, so Prometheus/Otel exporters see event workloads alongside query metrics.
23+
- Added adapter-specific runtime hints (asyncmy, duckdb, bigquery/adbc) plus a ``poll_interval`` extension option so operators can tune leases and cadence per database.
24+
- Publishing, dequeue, ack, nack, and shutdown operations now emit ``sqlspec.events.*`` spans whenever ``extension_config["otel"]`` is enabled, giving full trace coverage without extra plumbing.
25+
- Documented adapter-specific guidance (asyncpg, psycopg, psqlpy, asyncmy, duckdb, oracle) and added a DuckDB integration test to cover the queue fallback path.
26+
1327
v0.33.0 - Configuration Parameter Standardization (BREAKING CHANGE)
1428
--------------------------------------------------------------------
1529

docs/examples/usage/usage_query_builder_10.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def test_example_10(tmp_path: Path) -> None:
2626
# start-example
2727
# Multiple value sets
2828
query = (
29-
sql.insert("users")
29+
sql
30+
.insert("users")
3031
.columns("name", "email")
3132
.values("Alice", "[email protected]")
3233
.values("Bob", "[email protected]")

0 commit comments

Comments
 (0)