dbkit-sql 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
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.
- dbkit/__init__.py +1 -1
- dbkit/_async/transaction.py +48 -0
- dbkit/_sync/transaction.py +48 -0
- dbkit/integrations/__init__.py +12 -0
- dbkit/integrations/outbox.py +158 -0
- {dbkit_sql-0.2.0.dist-info → dbkit_sql-0.3.0.dist-info}/METADATA +9 -4
- {dbkit_sql-0.2.0.dist-info → dbkit_sql-0.3.0.dist-info}/RECORD +10 -9
- {dbkit_sql-0.2.0.dist-info → dbkit_sql-0.3.0.dist-info}/WHEEL +0 -0
- {dbkit_sql-0.2.0.dist-info → dbkit_sql-0.3.0.dist-info}/entry_points.txt +0 -0
- {dbkit_sql-0.2.0.dist-info → dbkit_sql-0.3.0.dist-info}/licenses/LICENSE +0 -0
dbkit/__init__.py
CHANGED
dbkit/_async/transaction.py
CHANGED
|
@@ -18,6 +18,7 @@ from sqlalchemy.ext.asyncio import AsyncConnection, AsyncEngine
|
|
|
18
18
|
|
|
19
19
|
from .._core.errors import (
|
|
20
20
|
DatabaseCommitUnknownError,
|
|
21
|
+
DatabaseUnsupportedOperationError,
|
|
21
22
|
classify,
|
|
22
23
|
is_connection_error,
|
|
23
24
|
)
|
|
@@ -63,6 +64,53 @@ class AsyncTransactionScope(AsyncConnectionScope):
|
|
|
63
64
|
else:
|
|
64
65
|
await nested.commit()
|
|
65
66
|
|
|
67
|
+
async def advisory_xact_lock(self, key: int | str) -> None:
|
|
68
|
+
"""Acquire a transaction-scoped PostgreSQL advisory lock, blocking until granted (§11.7).
|
|
69
|
+
|
|
70
|
+
The lock is held for the remainder of THIS transaction and released automatically on
|
|
71
|
+
``COMMIT``/``ROLLBACK`` — there is no manual unlock, so it can never leak. It serializes
|
|
72
|
+
transactions that lock the same ``key``: a second locker of the same key blocks until the
|
|
73
|
+
first transaction ends. Nothing else is blocked (advisory locks are cooperative — they only
|
|
74
|
+
guard code paths that agree to take the same lock), so it is the tool for serializing a
|
|
75
|
+
read-modify-write on a logical entity without locking its rows.
|
|
76
|
+
|
|
77
|
+
``key`` is either a 64-bit ``int`` (used directly as the lock key) or a ``str`` (hashed to a
|
|
78
|
+
``bigint`` server-side via ``hashtextextended(key, 0)``). It is always passed as a bound
|
|
79
|
+
parameter — never string-interpolated.
|
|
80
|
+
|
|
81
|
+
The wait respects the transaction's ``lock_timeout`` (set via
|
|
82
|
+
:meth:`~dbkit.AsyncDatabase.transaction`'s ``lock_timeout=`` argument): a wait that exceeds
|
|
83
|
+
it raises :class:`~dbkit.errors.DatabaseLockTimeoutError` (retryable). PostgreSQL only;
|
|
84
|
+
raises :class:`~dbkit.errors.DatabaseUnsupportedOperationError` otherwise.
|
|
85
|
+
"""
|
|
86
|
+
await self._advisory_lock("pg_advisory_xact_lock", key, name="advisory_xact_lock")
|
|
87
|
+
|
|
88
|
+
async def try_advisory_xact_lock(self, key: int | str) -> bool:
|
|
89
|
+
"""Try to take a transaction-scoped advisory lock without blocking (§11.7).
|
|
90
|
+
|
|
91
|
+
Returns ``True`` if the lock was granted (held until this transaction ends), ``False`` if
|
|
92
|
+
another transaction already holds it. Never waits, so ``lock_timeout`` does not apply — use
|
|
93
|
+
this to fail fast (e.g. skip work another worker is already doing) instead of queuing.
|
|
94
|
+
``key`` and dialect rules match :meth:`advisory_xact_lock`.
|
|
95
|
+
"""
|
|
96
|
+
result = await self._advisory_lock(
|
|
97
|
+
"pg_try_advisory_xact_lock", key, name="try_advisory_xact_lock"
|
|
98
|
+
)
|
|
99
|
+
return bool(result)
|
|
100
|
+
|
|
101
|
+
async def _advisory_lock(self, func: str, key: int | str, *, name: str) -> Any:
|
|
102
|
+
"""Run one advisory-lock function (``func`` is an internal literal, ``key`` is bound)."""
|
|
103
|
+
if not self._is_postgres:
|
|
104
|
+
raise DatabaseUnsupportedOperationError("advisory locks require PostgreSQL")
|
|
105
|
+
arg = "hashtextextended(:key, 0)" if isinstance(key, str) else ":key"
|
|
106
|
+
try:
|
|
107
|
+
cursor = await self._conn.execute(text(f"SELECT {func}({arg})"), {"key": key})
|
|
108
|
+
return cursor.scalar()
|
|
109
|
+
except Exception as exc:
|
|
110
|
+
raise classify(
|
|
111
|
+
exc, query_name=name, database_name=self._database, role=self._role
|
|
112
|
+
) from exc
|
|
113
|
+
|
|
66
114
|
|
|
67
115
|
class _AsyncTransactionManager:
|
|
68
116
|
"""Async context manager implementing the transaction lifecycle (§11.1, §11.3)."""
|
dbkit/_sync/transaction.py
CHANGED
|
@@ -21,6 +21,7 @@ from sqlalchemy import Connection, Engine
|
|
|
21
21
|
|
|
22
22
|
from .._core.errors import (
|
|
23
23
|
DatabaseCommitUnknownError,
|
|
24
|
+
DatabaseUnsupportedOperationError,
|
|
24
25
|
classify,
|
|
25
26
|
is_connection_error,
|
|
26
27
|
)
|
|
@@ -66,6 +67,53 @@ class TransactionScope(ConnectionScope):
|
|
|
66
67
|
else:
|
|
67
68
|
nested.commit()
|
|
68
69
|
|
|
70
|
+
def advisory_xact_lock(self, key: int | str) -> None:
|
|
71
|
+
"""Acquire a transaction-scoped PostgreSQL advisory lock, blocking until granted (§11.7).
|
|
72
|
+
|
|
73
|
+
The lock is held for the remainder of THIS transaction and released automatically on
|
|
74
|
+
``COMMIT``/``ROLLBACK`` — there is no manual unlock, so it can never leak. It serializes
|
|
75
|
+
transactions that lock the same ``key``: a second locker of the same key blocks until the
|
|
76
|
+
first transaction ends. Nothing else is blocked (advisory locks are cooperative — they only
|
|
77
|
+
guard code paths that agree to take the same lock), so it is the tool for serializing a
|
|
78
|
+
read-modify-write on a logical entity without locking its rows.
|
|
79
|
+
|
|
80
|
+
``key`` is either a 64-bit ``int`` (used directly as the lock key) or a ``str`` (hashed to a
|
|
81
|
+
``bigint`` server-side via ``hashtextextended(key, 0)``). It is always passed as a bound
|
|
82
|
+
parameter — never string-interpolated.
|
|
83
|
+
|
|
84
|
+
The wait respects the transaction's ``lock_timeout`` (set via
|
|
85
|
+
:meth:`~dbkit.Database.transaction`'s ``lock_timeout=`` argument): a wait that exceeds
|
|
86
|
+
it raises :class:`~dbkit.errors.DatabaseLockTimeoutError` (retryable). PostgreSQL only;
|
|
87
|
+
raises :class:`~dbkit.errors.DatabaseUnsupportedOperationError` otherwise.
|
|
88
|
+
"""
|
|
89
|
+
self._advisory_lock("pg_advisory_xact_lock", key, name="advisory_xact_lock")
|
|
90
|
+
|
|
91
|
+
def try_advisory_xact_lock(self, key: int | str) -> bool:
|
|
92
|
+
"""Try to take a transaction-scoped advisory lock without blocking (§11.7).
|
|
93
|
+
|
|
94
|
+
Returns ``True`` if the lock was granted (held until this transaction ends), ``False`` if
|
|
95
|
+
another transaction already holds it. Never waits, so ``lock_timeout`` does not apply — use
|
|
96
|
+
this to fail fast (e.g. skip work another worker is already doing) instead of queuing.
|
|
97
|
+
``key`` and dialect rules match :meth:`advisory_xact_lock`.
|
|
98
|
+
"""
|
|
99
|
+
result = self._advisory_lock(
|
|
100
|
+
"pg_try_advisory_xact_lock", key, name="try_advisory_xact_lock"
|
|
101
|
+
)
|
|
102
|
+
return bool(result)
|
|
103
|
+
|
|
104
|
+
def _advisory_lock(self, func: str, key: int | str, *, name: str) -> Any:
|
|
105
|
+
"""Run one advisory-lock function (``func`` is an internal literal, ``key`` is bound)."""
|
|
106
|
+
if not self._is_postgres:
|
|
107
|
+
raise DatabaseUnsupportedOperationError("advisory locks require PostgreSQL")
|
|
108
|
+
arg = "hashtextextended(:key, 0)" if isinstance(key, str) else ":key"
|
|
109
|
+
try:
|
|
110
|
+
cursor = self._conn.execute(text(f"SELECT {func}({arg})"), {"key": key})
|
|
111
|
+
return cursor.scalar()
|
|
112
|
+
except Exception as exc:
|
|
113
|
+
raise classify(
|
|
114
|
+
exc, query_name=name, database_name=self._database, role=self._role
|
|
115
|
+
) from exc
|
|
116
|
+
|
|
69
117
|
|
|
70
118
|
class _TransactionManager:
|
|
71
119
|
"""Async context manager implementing the transaction lifecycle (§11.1, §11.3)."""
|
dbkit/integrations/__init__.py
CHANGED
|
@@ -10,12 +10,24 @@ from .inbox import (
|
|
|
10
10
|
partitioned_inbox_ddl,
|
|
11
11
|
process_once,
|
|
12
12
|
)
|
|
13
|
+
from .outbox import (
|
|
14
|
+
drain,
|
|
15
|
+
enqueue,
|
|
16
|
+
outbox_ddl,
|
|
17
|
+
outbox_month_partition_ddl,
|
|
18
|
+
partitioned_outbox_ddl,
|
|
19
|
+
)
|
|
13
20
|
|
|
14
21
|
__all__ = [
|
|
15
22
|
"BatchCollector",
|
|
16
23
|
"ack_after_commit",
|
|
24
|
+
"drain",
|
|
25
|
+
"enqueue",
|
|
17
26
|
"inbox_ddl",
|
|
18
27
|
"inbox_month_partition_ddl",
|
|
28
|
+
"outbox_ddl",
|
|
29
|
+
"outbox_month_partition_ddl",
|
|
19
30
|
"partitioned_inbox_ddl",
|
|
31
|
+
"partitioned_outbox_ddl",
|
|
20
32
|
"process_once",
|
|
21
33
|
]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Transactional-outbox helpers for reliable event publishing (§28).
|
|
2
|
+
|
|
3
|
+
The classic outbox pattern: instead of writing to the database and then publishing to a broker as
|
|
4
|
+
two independent steps (which can leave them inconsistent if the process dies between them), you
|
|
5
|
+
INSERT the event into an outbox table **in the same transaction as the business write**. The row
|
|
6
|
+
and the write commit atomically — the event exists if and only if the business change persisted. A
|
|
7
|
+
separate **relay** then reads unsent rows and publishes them to the broker, marking each sent.
|
|
8
|
+
|
|
9
|
+
Delivery is **at-least-once** (a crash after the broker accepts a message but before the relay
|
|
10
|
+
marks it sent replays it) — pair this with the consumer-side inbox
|
|
11
|
+
(:mod:`dbkit.integrations.inbox`) for end-to-end effectively-once. This is a **single-shard**
|
|
12
|
+
outbox: the outbox table lives on the same
|
|
13
|
+
database as the business write. dbkit does not coordinate cross-shard/distributed transactions —
|
|
14
|
+
for multi-shard fan-out, run one outbox per shard.
|
|
15
|
+
|
|
16
|
+
Async helpers targeting :class:`~dbkit.AsyncDatabase`; the DDL is frontend-agnostic. It is
|
|
17
|
+
schema-agnostic: you pass the table name, and the payload is opaque JSON — no dbkit- or
|
|
18
|
+
product-specific columns.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import json
|
|
24
|
+
from collections.abc import Awaitable, Callable, Mapping
|
|
25
|
+
from typing import Any
|
|
26
|
+
|
|
27
|
+
from .._core.query import sql
|
|
28
|
+
from .._core.routing import DatabaseTarget
|
|
29
|
+
|
|
30
|
+
DEFAULT_OUTBOX_TABLE = "outbox_messages"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def outbox_ddl(table: str = DEFAULT_OUTBOX_TABLE) -> str:
|
|
34
|
+
"""DDL for the outbox table (§28.4).
|
|
35
|
+
|
|
36
|
+
Columns: ``id`` (monotonic ``bigserial`` — relay order + cursor), ``topic`` (routing key),
|
|
37
|
+
``payload`` (opaque ``jsonb`` event body), ``created_at``, and ``sent_at`` (``NULL`` until the
|
|
38
|
+
relay publishes it). A partial index on the unsent rows keeps the relay's "next batch" scan
|
|
39
|
+
cheap regardless of how many already-sent rows remain. Time-partition it in production for cheap
|
|
40
|
+
pruning of sent rows — see :func:`partitioned_outbox_ddl`/:func:`outbox_month_partition_ddl`.
|
|
41
|
+
"""
|
|
42
|
+
return f"""
|
|
43
|
+
CREATE TABLE IF NOT EXISTS {table} (
|
|
44
|
+
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
45
|
+
topic TEXT NOT NULL,
|
|
46
|
+
payload JSONB NOT NULL,
|
|
47
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
48
|
+
sent_at TIMESTAMPTZ
|
|
49
|
+
);
|
|
50
|
+
CREATE INDEX IF NOT EXISTS {table}_unsent_idx ON {table} (id) WHERE sent_at IS NULL
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def partitioned_outbox_ddl(table: str = DEFAULT_OUTBOX_TABLE) -> str:
|
|
55
|
+
"""DDL for a **partitioned** outbox table, range-partitioned by ``created_at`` (§28.4).
|
|
56
|
+
|
|
57
|
+
An unbounded outbox grows without limit as events accumulate; range-partitioning by month makes
|
|
58
|
+
pruning old (already-sent) data a cheap ``DROP TABLE`` on a partition instead of a slow
|
|
59
|
+
``DELETE``. The partition key must be part of the primary key for declarative partitioning, so
|
|
60
|
+
this variant keys on ``(id, created_at)``. Create each month's partition with
|
|
61
|
+
:func:`outbox_month_partition_ddl` (typically from a scheduled job a month ahead); drop
|
|
62
|
+
partitions once every row in them has been sent and is past any audit window.
|
|
63
|
+
"""
|
|
64
|
+
return f"""
|
|
65
|
+
CREATE TABLE IF NOT EXISTS {table} (
|
|
66
|
+
id BIGINT GENERATED ALWAYS AS IDENTITY,
|
|
67
|
+
topic TEXT NOT NULL,
|
|
68
|
+
payload JSONB NOT NULL,
|
|
69
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
70
|
+
sent_at TIMESTAMPTZ,
|
|
71
|
+
PRIMARY KEY (id, created_at)
|
|
72
|
+
) PARTITION BY RANGE (created_at)
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def outbox_month_partition_ddl(year: int, month: int, *, table: str = DEFAULT_OUTBOX_TABLE) -> str:
|
|
77
|
+
"""DDL for one calendar-month partition of :func:`partitioned_outbox_ddl`'s table.
|
|
78
|
+
|
|
79
|
+
``year``/``month`` are passed explicitly (not computed from the current date) so this stays a
|
|
80
|
+
pure function — call it with whatever month you need created, e.g. from a scheduled job that
|
|
81
|
+
creates the next month a few days before it starts.
|
|
82
|
+
"""
|
|
83
|
+
start = f"{year:04d}-{month:02d}-01"
|
|
84
|
+
next_year, next_month = (year + 1, 1) if month == 12 else (year, month + 1)
|
|
85
|
+
end = f"{next_year:04d}-{next_month:02d}-01"
|
|
86
|
+
partition_name = f"{table}_{year:04d}_{month:02d}"
|
|
87
|
+
return f"""
|
|
88
|
+
CREATE TABLE IF NOT EXISTS {partition_name} PARTITION OF {table}
|
|
89
|
+
FOR VALUES FROM ('{start}') TO ('{end}')
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
async def enqueue(
|
|
94
|
+
tx: Any,
|
|
95
|
+
*,
|
|
96
|
+
topic: str,
|
|
97
|
+
payload: Mapping[str, Any],
|
|
98
|
+
table: str = DEFAULT_OUTBOX_TABLE,
|
|
99
|
+
) -> int:
|
|
100
|
+
"""Insert one event into the outbox **on the caller's transaction** ``tx`` and return its id.
|
|
101
|
+
|
|
102
|
+
Call this inside a ``db.transaction(...)`` block alongside the business writes so the event and
|
|
103
|
+
the change commit atomically::
|
|
104
|
+
|
|
105
|
+
async with db.transaction(target=t) as tx:
|
|
106
|
+
await tx.execute(UPDATE_ORDER, params)
|
|
107
|
+
await enqueue(tx, topic="order.completed", payload={"order_id": oid})
|
|
108
|
+
|
|
109
|
+
``payload`` is serialized to ``jsonb`` and bound as a parameter (never interpolated).
|
|
110
|
+
"""
|
|
111
|
+
new_id = await tx.fetch_value(
|
|
112
|
+
sql(
|
|
113
|
+
f"INSERT INTO {table} (topic, payload) "
|
|
114
|
+
"VALUES (:topic, CAST(:payload AS jsonb)) RETURNING id"
|
|
115
|
+
),
|
|
116
|
+
{"topic": topic, "payload": json.dumps(dict(payload))},
|
|
117
|
+
)
|
|
118
|
+
return int(new_id)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
async def drain(
|
|
122
|
+
db: Any,
|
|
123
|
+
*,
|
|
124
|
+
target: DatabaseTarget,
|
|
125
|
+
publish: Callable[[Mapping[str, Any]], Awaitable[None]],
|
|
126
|
+
batch_size: int = 100,
|
|
127
|
+
table: str = DEFAULT_OUTBOX_TABLE,
|
|
128
|
+
) -> int:
|
|
129
|
+
"""Relay a batch of unsent outbox rows to ``publish``, then mark them sent. Returns the count.
|
|
130
|
+
|
|
131
|
+
Claims up to ``batch_size`` unsent rows in id order with ``FOR UPDATE SKIP LOCKED`` — so many
|
|
132
|
+
relay workers can run concurrently without blocking or double-claiming — publishes each via the
|
|
133
|
+
``publish`` callback (receives a mapping with ``id``/``topic``/``payload``/``created_at``), then
|
|
134
|
+
stamps ``sent_at`` for the whole batch and commits. Everything runs in one transaction: if
|
|
135
|
+
``publish`` raises, the claim rolls back and the rows are retried on the next :func:`drain`.
|
|
136
|
+
|
|
137
|
+
Delivery is **at-least-once**: a crash after the broker accepts a message but before commit
|
|
138
|
+
replays it. Make ``publish`` idempotent or dedupe on the consumer
|
|
139
|
+
(:mod:`dbkit.integrations.inbox`). Loop :func:`drain` from a relay worker (a return of 0 means
|
|
140
|
+
the outbox is momentarily empty).
|
|
141
|
+
"""
|
|
142
|
+
async with db.transaction(target=target) as tx:
|
|
143
|
+
rows = await tx.fetch_all(
|
|
144
|
+
sql(
|
|
145
|
+
f"SELECT id, topic, payload, created_at FROM {table} "
|
|
146
|
+
"WHERE sent_at IS NULL ORDER BY id FOR UPDATE SKIP LOCKED LIMIT :n"
|
|
147
|
+
),
|
|
148
|
+
{"n": batch_size},
|
|
149
|
+
)
|
|
150
|
+
if not rows:
|
|
151
|
+
return 0
|
|
152
|
+
for row in rows:
|
|
153
|
+
await publish(dict(row))
|
|
154
|
+
await tx.execute(
|
|
155
|
+
sql(f"UPDATE {table} SET sent_at = now() WHERE id = ANY(:ids)"),
|
|
156
|
+
{"ids": [row["id"] for row in rows]},
|
|
157
|
+
)
|
|
158
|
+
return len(rows)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dbkit-sql
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A thin, high-throughput SQL toolkit over SQLAlchemy Core — sync and async, ORM-free.
|
|
5
5
|
Project-URL: Homepage, https://github.com/talaatmagdyx/dbkit-sql
|
|
6
6
|
Project-URL: Source, https://github.com/talaatmagdyx/dbkit-sql
|
|
@@ -395,8 +395,9 @@ target = DatabaseTarget(database="app", role="read", shard_key=f"tenant-{tenant_
|
|
|
395
395
|
Pluggable resolvers (hash / range / directory / callable), replica routing with a
|
|
396
396
|
read-your-writes override (pins reads to the primary for the scope — not lag-aware replica
|
|
397
397
|
tracking), and LRU engine eviction bounded by `max_engines` so a dynamic or unbounded shard-key
|
|
398
|
-
space still keeps a bounded number of live connections. No cross-shard transactions —
|
|
399
|
-
|
|
398
|
+
space still keeps a bounded number of live connections. No cross-shard transactions — for
|
|
399
|
+
multi-shard writes pair with a saga; for reliable event publishing on a **single** shard use the
|
|
400
|
+
built-in transactional outbox (`dbkit.integrations`, 0.3).
|
|
400
401
|
|
|
401
402
|
### Dynamic registration (0.2)
|
|
402
403
|
|
|
@@ -427,6 +428,8 @@ process-wide connection budget. See the
|
|
|
427
428
|
| `unnest()` bulk strategy | Array-parameter bulk insert/upsert — ~29× a naive `execute_many` loop |
|
|
428
429
|
| `db.copy_records` | PostgreSQL COPY for the largest ingest jobs |
|
|
429
430
|
| Transactional inbox | Effectively-once consumer processing — dedup and business write share one transaction |
|
|
431
|
+
| Transactional outbox | Reliable event publishing — event row + business write share one transaction, at-least-once relay (`FOR UPDATE SKIP LOCKED`) |
|
|
432
|
+
| Advisory locks | Transaction-scoped `pg_advisory_xact_lock` on a logical key — serialize a read-modify-write without locking rows; auto-released at commit |
|
|
430
433
|
| PgBouncer-compatible pooling | A mode for transaction-pooling PgBouncer deployments |
|
|
431
434
|
| psycopg pipeline mode | A raw escape hatch for pipelined round-trips, opt-in |
|
|
432
435
|
| `PrometheusMetrics` / OTel metrics & tracing | Structured observability, cost measured per adapter |
|
|
@@ -512,6 +515,8 @@ dbkit wraps `create_async_engine`/`create_engine`, so migration is incremental,
|
|
|
512
515
|
|---|---|
|
|
513
516
|
| See the smallest working consumer | [`quickstart_async.py`](examples/quickstart_async.py) · [`quickstart_sync.py`](examples/quickstart_sync.py) |
|
|
514
517
|
| Use explicit transactions & savepoints | [`transactions_savepoints.py`](examples/transactions_savepoints.py) |
|
|
518
|
+
| Serialize work with advisory locks | [`advisory_locks.py`](examples/advisory_locks.py) |
|
|
519
|
+
| Publish events via the transactional outbox | [`transactional_outbox.py`](examples/transactional_outbox.py) |
|
|
515
520
|
| Handle classified errors | [`error_handling.py`](examples/error_handling.py) |
|
|
516
521
|
| Wire retries + the circuit breaker | [`retries_and_circuit_breaker.py`](examples/retries_and_circuit_breaker.py) |
|
|
517
522
|
| Stream millions of rows | [`streaming.py`](examples/streaming.py) · [`streaming_checkpoint_resume.py`](examples/streaming_checkpoint_resume.py) |
|
|
@@ -536,7 +541,7 @@ dbkit/
|
|
|
536
541
|
_sync/ # generated from _async/ via tools/run_unasync.py — never edited by hand
|
|
537
542
|
observability/ # structured logging, Prometheus, OpenTelemetry metrics/tracing
|
|
538
543
|
postgres/ # COPY, pipeline mode, unnest() bulk strategy — Postgres-only escape hatches
|
|
539
|
-
integrations/ # transactional inbox (dedup consumer), BatchCollector
|
|
544
|
+
integrations/ # transactional inbox (dedup consumer) + outbox (reliable publish), BatchCollector
|
|
540
545
|
cli/ # config-validate, check, pools, engines, connection-budget, metrics
|
|
541
546
|
```
|
|
542
547
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
dbkit/__init__.py,sha256=
|
|
1
|
+
dbkit/__init__.py,sha256=GOnP51rnLD47S00MOnwFxGtikEK_tnRa8DkSlKZuPrg,1728
|
|
2
2
|
dbkit/_pool.py,sha256=EiOMtxIsMvucUmPU0wGZQfJxgAxK-zdX382RmBLKSuA,7673
|
|
3
3
|
dbkit/errors.py,sha256=Gu2s0fT52TTq1WMW2m5Uxcej_AoQTmzVfrSMv9s7Nhs,207
|
|
4
4
|
dbkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -11,7 +11,7 @@ dbkit/_async/executor.py,sha256=vyvyFw3jXaDvt_df8aBPmJ0Lwh9oq1SkWwiDRpW-ZGU,1486
|
|
|
11
11
|
dbkit/_async/health.py,sha256=KTjGJ_f2RLLmnopUGTUpfKdq3_KIlYUtmM6fkTXenKQ,1533
|
|
12
12
|
dbkit/_async/resilience.py,sha256=Rti3BkV0sSue8hbTsaiJbx6YA3PXJ34CCd8ImCJZcxA,5987
|
|
13
13
|
dbkit/_async/streaming.py,sha256=EjanXAUOCRhXgwohXHrjd7noXr19ZKjNoZFwmIOEJ2w,5093
|
|
14
|
-
dbkit/_async/transaction.py,sha256=
|
|
14
|
+
dbkit/_async/transaction.py,sha256=0ZK9Fgece_S03-QiAkHuFzK34xTyeF_OZ3s1gX6t-24,13486
|
|
15
15
|
dbkit/_core/__init__.py,sha256=OQD-7nAVm6u0rxe-wzKLrA6qmLQqtfAAWCEtIe-eJHk,73
|
|
16
16
|
dbkit/_core/bulk.py,sha256=5MIHLycFDz0cOCrSv6rA4vkRBMejHV47v6Nyjszeq1s,3681
|
|
17
17
|
dbkit/_core/circuit.py,sha256=R6WecYMhn0WvT9yTKJyIqaJcqvRtsSVEf6SfBqaRb6o,4599
|
|
@@ -36,13 +36,14 @@ dbkit/_sync/executor.py,sha256=eS_Y4o2lBF39rudPPLiaWVWV1g-Ulc97AFLmSFWndZg,14771
|
|
|
36
36
|
dbkit/_sync/health.py,sha256=Y99Zd_kYNhRkIo9slq0Z0c-QdbMyH4suJAlikmBX1Yc,1639
|
|
37
37
|
dbkit/_sync/resilience.py,sha256=NctTcZf0SWIGMgjErUy3XZ2dk8pvFyjIh_1Ut6JqzWs,6105
|
|
38
38
|
dbkit/_sync/streaming.py,sha256=fHo44OOEpExRM7wfVU-apJa0MHCnrrgIW3x0b5V9wQ8,5114
|
|
39
|
-
dbkit/_sync/transaction.py,sha256=
|
|
39
|
+
dbkit/_sync/transaction.py,sha256=WhAPrTGGJSzUD9pjiZc4NdyXBkMdOdL0rX2h_MbPQQc,13299
|
|
40
40
|
dbkit/cli/__init__.py,sha256=uxJm6uDiwk-B0ENvXlvWTutiIV2HwBsB73fTKeDrShs,56
|
|
41
41
|
dbkit/cli/main.py,sha256=PcNkm1zTZIeOYk5FtTJNC0OaJKXyYzhxCdkfzSlY8iY,9616
|
|
42
|
-
dbkit/integrations/__init__.py,sha256=
|
|
42
|
+
dbkit/integrations/__init__.py,sha256=r_DAMCv9nuSgnpe5xdDX7FcbTpYLJetGrxvRmZ5xNE4,692
|
|
43
43
|
dbkit/integrations/batch.py,sha256=oGqlrdgRxSPMM3QYPiFqv2pdqcjpgwnpy8x0Ra6YEg4,2958
|
|
44
44
|
dbkit/integrations/fastapi.py,sha256=kZeR90Qkmxc0ZUuWnoTAP-mbdXDtZA3SjEQ4uinDVVY,5059
|
|
45
45
|
dbkit/integrations/inbox.py,sha256=HSXoyqMC1ez08pZkrTWY7LZ-1fh7lAhWYUtQS7WKfBA,6406
|
|
46
|
+
dbkit/integrations/outbox.py,sha256=gCPJDQgggJDzzeIvGPEBkMlxqIkWbvZSg4lyPLt6LPg,7056
|
|
46
47
|
dbkit/observability/__init__.py,sha256=g3mV9HE0z36mhx1Ybuw-SJINvk8hQLyoVH-aFFN7DoU,598
|
|
47
48
|
dbkit/observability/logging.py,sha256=EUf1CgmiQ02ggKWgyOEE5UxZLlslVc2yevmSkr4QZCs,4848
|
|
48
49
|
dbkit/observability/metrics.py,sha256=zk1hR-gawS6joN-btng1YecYGKnjJfVPoyHCWxSJccw,4655
|
|
@@ -54,8 +55,8 @@ dbkit/postgres/copy.py,sha256=uqoQhB_a4rHc7ahB2tlX_7fdUtJGgebwZCWX-PhQU40,2947
|
|
|
54
55
|
dbkit/postgres/pipeline.py,sha256=Ym4roIt5Tv4RiKDKVxfyDjE8An86VAZCUInHwgz39Gk,2000
|
|
55
56
|
dbkit/postgres/unnest.py,sha256=lSViVkKQ8K-NoxEl2UtFSau697wnMFdBJDBKWbE6ioM,3572
|
|
56
57
|
dbkit/testing/__init__.py,sha256=Ja5C_sqYTKHlJwL7bce9y7umGNwSkQ_jnrCG-iCNjvE,9551
|
|
57
|
-
dbkit_sql-0.
|
|
58
|
-
dbkit_sql-0.
|
|
59
|
-
dbkit_sql-0.
|
|
60
|
-
dbkit_sql-0.
|
|
61
|
-
dbkit_sql-0.
|
|
58
|
+
dbkit_sql-0.3.0.dist-info/METADATA,sha256=tE5Izz8p_bX_MC7-iu__0PagO_zxRfwsqRKLsNdh3Xs,28826
|
|
59
|
+
dbkit_sql-0.3.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
60
|
+
dbkit_sql-0.3.0.dist-info/entry_points.txt,sha256=lkcS_gAba07Xq6Tm4xuEGSvEqQEnVUG_1sfsO9L9O6A,46
|
|
61
|
+
dbkit_sql-0.3.0.dist-info/licenses/LICENSE,sha256=HPDJs06q_YVI0ZFnpF12thVUr-dC5pxTow19W6z-YXQ,1075
|
|
62
|
+
dbkit_sql-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|