walbox 1.0.0__tar.gz
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.
- walbox-1.0.0/LICENSE +21 -0
- walbox-1.0.0/PKG-INFO +156 -0
- walbox-1.0.0/README.md +129 -0
- walbox-1.0.0/pyproject.toml +173 -0
- walbox-1.0.0/pyproject.toml.orig +207 -0
- walbox-1.0.0/walbox/__init__.py +27 -0
- walbox-1.0.0/walbox/abc.py +184 -0
- walbox-1.0.0/walbox/builder.py +50 -0
- walbox-1.0.0/walbox/checkpoint.py +191 -0
- walbox-1.0.0/walbox/client.py +383 -0
- walbox-1.0.0/walbox/errors.py +114 -0
- walbox-1.0.0/walbox/pgoutput.py +897 -0
- walbox-1.0.0/walbox/protocol.py +165 -0
- walbox-1.0.0/walbox/transaction.py +392 -0
- walbox-1.0.0/walbox/transport.py +383 -0
walbox-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mochama Adriano
|
|
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.
|
walbox-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: walbox
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Async PostgreSQL logical-replication runtime for the transactional outbox pattern
|
|
5
|
+
Keywords: postgresql,logical-replication,outbox,asyncio,cdc,change-data-capture
|
|
6
|
+
Author: Mochama Adriano
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Framework :: AsyncIO
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Database
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Dist: psycopg>=3.0,<4
|
|
20
|
+
Requires-Python: >=3.13
|
|
21
|
+
Project-URL: Homepage, https://github.com/mochams/walbox
|
|
22
|
+
Project-URL: Documentation, https://mochams.github.io/walbox/
|
|
23
|
+
Project-URL: Repository, https://github.com/mochams/walbox
|
|
24
|
+
Project-URL: Issues, https://github.com/mochams/walbox/issues
|
|
25
|
+
Project-URL: Author, https://github.com/mochams
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# walbox
|
|
29
|
+
|
|
30
|
+
[](https://pypi.org/project/walbox/)
|
|
31
|
+
[](https://github.com/mochams/walbox/actions/workflows/ci.yml)
|
|
32
|
+
[](https://www.python.org/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
|
|
35
|
+
Async Python runtime for consuming PostgreSQL logical replication as a stream of committed transactions.
|
|
36
|
+
|
|
37
|
+
**[📖 Documentation](https://mochams.github.io/walbox/) · [⚡ Quickstart](https://mochams.github.io/walbox/getting-started/quickstart/)**
|
|
38
|
+
|
|
39
|
+
**Some reasons you might want to use walbox:**
|
|
40
|
+
|
|
41
|
+
- **You want to react to database changes in real time** without polling tables or adding fragile trigger-based workarounds.
|
|
42
|
+
- **You care about reliable delivery**: walbox checkpoints progress durably so it can resume cleanly after restarts or connection drops.
|
|
43
|
+
- **You’re building around the transactional outbox pattern** and want a consumer that preserves commit ordering and handles recovery sensibly.
|
|
44
|
+
- **You want backpressure built in**, so a slow handler does not turn into unbounded memory growth or silent data loss.
|
|
45
|
+
- **You need a Python async consumer** that plugs directly into PostgreSQL logical replication instead of shoving data through a separate broker.
|
|
46
|
+
- **You want to stream changes from published tables** without writing your own replication client, reconnect logic, or checkpoint tracking.
|
|
47
|
+
- **You want operational visibility**: retries, lag, queue depth, and checkpoint timing are all surfaced so production behavior is easier to reason about.
|
|
48
|
+
|
|
49
|
+
## Guarantees
|
|
50
|
+
|
|
51
|
+
- **At-least-once delivery**: a durable local checkpoint ensures committed events are not silently skipped
|
|
52
|
+
- **Transactional consistency**: outbox events are committed atomically with your business data
|
|
53
|
+
- **No polling**: consumes changes directly from PostgreSQL logical replication
|
|
54
|
+
- **Bounded backpressure**: queue limits prevent a slow handler from accumulating unbounded memory
|
|
55
|
+
- **Automatic recovery**: resumes from the last durable checkpoint on restart
|
|
56
|
+
- **Graceful shutdown**: lets in-flight work complete before exiting
|
|
57
|
+
- **Asyncio-native**: built for Python's async runtime
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
pip install walbox
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Psycopg 3 is the only Python dependency. By default it uses your system's `libpq`; if you don't have it installed, use the binary distribution: `pip install walbox psycopg[binary]`.
|
|
66
|
+
|
|
67
|
+
## Example
|
|
68
|
+
|
|
69
|
+
PostgreSQL setup (one-time):
|
|
70
|
+
|
|
71
|
+
```sql
|
|
72
|
+
CREATE TABLE outbox (
|
|
73
|
+
id BIGSERIAL PRIMARY KEY, entity_type TEXT, entity_id TEXT,
|
|
74
|
+
event_type TEXT, payload JSONB, created_at TIMESTAMPTZ DEFAULT now()
|
|
75
|
+
);
|
|
76
|
+
CREATE PUBLICATION walbox_pub FOR TABLE outbox;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Handler (`handler.py`):
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
import asyncio
|
|
83
|
+
from walbox import (
|
|
84
|
+
ChangeKind,
|
|
85
|
+
CheckpointHandle,
|
|
86
|
+
Transaction,
|
|
87
|
+
Walbox,
|
|
88
|
+
WalboxOptions,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
async def handle(tx: Transaction, checkpoint: CheckpointHandle) -> None:
|
|
93
|
+
for change in tx.changes:
|
|
94
|
+
if change.table == "public.outbox" and change.kind == ChangeKind.INSERT:
|
|
95
|
+
print(f"Event: {change.new}")
|
|
96
|
+
await checkpoint.save(tx.commit_lsn)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
async def main():
|
|
100
|
+
options = WalboxOptions(
|
|
101
|
+
consumer_name="app",
|
|
102
|
+
dsn="postgresql://user:password@localhost/db",
|
|
103
|
+
slot_name="slot",
|
|
104
|
+
publication_name="walbox_pub",
|
|
105
|
+
)
|
|
106
|
+
client = Walbox.build(options)
|
|
107
|
+
await client.run(handle)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
asyncio.run(main())
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Run it, then insert a row:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
python handler.py
|
|
117
|
+
# In another terminal:
|
|
118
|
+
INSERT INTO outbox (entity_type, entity_id, event_type, payload)
|
|
119
|
+
VALUES ('user', '42', 'created', '{"name":"Alice"}'::jsonb);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The handler receives the row and saves a durable checkpoint. On restart, it resumes from that checkpoint. No data loss.
|
|
123
|
+
|
|
124
|
+
See [**Examples**](https://github.com/mochams/walbox/tree/main/examples) for working patterns: publishing to a message broker, writing to a PostgreSQL sink with exactly-once effects, sharded concurrent handling, and metrics.
|
|
125
|
+
|
|
126
|
+
## Next steps
|
|
127
|
+
|
|
128
|
+
- **[Quickstart](https://mochams.github.io/walbox/getting-started/quickstart/)** (5 minutes): step-by-step setup
|
|
129
|
+
- **[Getting Started](https://mochams.github.io/walbox/getting-started/introduction/)**: concepts and guarantees
|
|
130
|
+
- **[Production Guide](https://mochams.github.io/walbox/production/architecture/)**: deployment, monitoring, configuration
|
|
131
|
+
|
|
132
|
+
## Status
|
|
133
|
+
|
|
134
|
+
walbox is at v1.0.0. It has 100% branch coverage, integration tests against real PostgreSQL, and went through three pre-release cycles (beta.1, beta.2, rc.1) to settle the API.
|
|
135
|
+
|
|
136
|
+
See [`CHANGELOG.md`](CHANGELOG.md) for what's changed release to release, and the [Upgrading guide](https://mochams.github.io/walbox/migration/) if you're on a pre-1.0.0 version.
|
|
137
|
+
|
|
138
|
+
## API Stability
|
|
139
|
+
|
|
140
|
+
As of v1.0.0, the following are stable and won't break within the 1.0.x series:
|
|
141
|
+
|
|
142
|
+
- `Walbox` (`build`, `build_with_pool`)
|
|
143
|
+
- `Client`
|
|
144
|
+
- `WalboxOptions`
|
|
145
|
+
- `ConnectionPool`
|
|
146
|
+
- `Transaction`
|
|
147
|
+
- `ChangeEvent`, `ChangeKind`
|
|
148
|
+
- `CheckpointHandle`
|
|
149
|
+
- `Metrics`, `MetricsCallback`
|
|
150
|
+
- `WalboxError` and its subclasses
|
|
151
|
+
|
|
152
|
+
`walbox.abc` and `walbox.checkpoint` expose the underlying protocols and the PostgreSQL checkpoint store, for advanced use like manual `Client` construction or a custom `CheckpointStore`. These are lower-level and may change shape in a minor release.
|
|
153
|
+
|
|
154
|
+
1.0.x releases can add fields or methods, but won't remove or change the meaning of anything listed above.
|
|
155
|
+
|
|
156
|
+
**Development**: see [`CONTRIBUTING.md`](CONTRIBUTING.md) for setup and [`LICENSE`](LICENSE) for terms.
|
walbox-1.0.0/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# walbox
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/walbox/)
|
|
4
|
+
[](https://github.com/mochams/walbox/actions/workflows/ci.yml)
|
|
5
|
+
[](https://www.python.org/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
Async Python runtime for consuming PostgreSQL logical replication as a stream of committed transactions.
|
|
9
|
+
|
|
10
|
+
**[📖 Documentation](https://mochams.github.io/walbox/) · [⚡ Quickstart](https://mochams.github.io/walbox/getting-started/quickstart/)**
|
|
11
|
+
|
|
12
|
+
**Some reasons you might want to use walbox:**
|
|
13
|
+
|
|
14
|
+
- **You want to react to database changes in real time** without polling tables or adding fragile trigger-based workarounds.
|
|
15
|
+
- **You care about reliable delivery**: walbox checkpoints progress durably so it can resume cleanly after restarts or connection drops.
|
|
16
|
+
- **You’re building around the transactional outbox pattern** and want a consumer that preserves commit ordering and handles recovery sensibly.
|
|
17
|
+
- **You want backpressure built in**, so a slow handler does not turn into unbounded memory growth or silent data loss.
|
|
18
|
+
- **You need a Python async consumer** that plugs directly into PostgreSQL logical replication instead of shoving data through a separate broker.
|
|
19
|
+
- **You want to stream changes from published tables** without writing your own replication client, reconnect logic, or checkpoint tracking.
|
|
20
|
+
- **You want operational visibility**: retries, lag, queue depth, and checkpoint timing are all surfaced so production behavior is easier to reason about.
|
|
21
|
+
|
|
22
|
+
## Guarantees
|
|
23
|
+
|
|
24
|
+
- **At-least-once delivery**: a durable local checkpoint ensures committed events are not silently skipped
|
|
25
|
+
- **Transactional consistency**: outbox events are committed atomically with your business data
|
|
26
|
+
- **No polling**: consumes changes directly from PostgreSQL logical replication
|
|
27
|
+
- **Bounded backpressure**: queue limits prevent a slow handler from accumulating unbounded memory
|
|
28
|
+
- **Automatic recovery**: resumes from the last durable checkpoint on restart
|
|
29
|
+
- **Graceful shutdown**: lets in-flight work complete before exiting
|
|
30
|
+
- **Asyncio-native**: built for Python's async runtime
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pip install walbox
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Psycopg 3 is the only Python dependency. By default it uses your system's `libpq`; if you don't have it installed, use the binary distribution: `pip install walbox psycopg[binary]`.
|
|
39
|
+
|
|
40
|
+
## Example
|
|
41
|
+
|
|
42
|
+
PostgreSQL setup (one-time):
|
|
43
|
+
|
|
44
|
+
```sql
|
|
45
|
+
CREATE TABLE outbox (
|
|
46
|
+
id BIGSERIAL PRIMARY KEY, entity_type TEXT, entity_id TEXT,
|
|
47
|
+
event_type TEXT, payload JSONB, created_at TIMESTAMPTZ DEFAULT now()
|
|
48
|
+
);
|
|
49
|
+
CREATE PUBLICATION walbox_pub FOR TABLE outbox;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Handler (`handler.py`):
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import asyncio
|
|
56
|
+
from walbox import (
|
|
57
|
+
ChangeKind,
|
|
58
|
+
CheckpointHandle,
|
|
59
|
+
Transaction,
|
|
60
|
+
Walbox,
|
|
61
|
+
WalboxOptions,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async def handle(tx: Transaction, checkpoint: CheckpointHandle) -> None:
|
|
66
|
+
for change in tx.changes:
|
|
67
|
+
if change.table == "public.outbox" and change.kind == ChangeKind.INSERT:
|
|
68
|
+
print(f"Event: {change.new}")
|
|
69
|
+
await checkpoint.save(tx.commit_lsn)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
async def main():
|
|
73
|
+
options = WalboxOptions(
|
|
74
|
+
consumer_name="app",
|
|
75
|
+
dsn="postgresql://user:password@localhost/db",
|
|
76
|
+
slot_name="slot",
|
|
77
|
+
publication_name="walbox_pub",
|
|
78
|
+
)
|
|
79
|
+
client = Walbox.build(options)
|
|
80
|
+
await client.run(handle)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
asyncio.run(main())
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Run it, then insert a row:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
python handler.py
|
|
90
|
+
# In another terminal:
|
|
91
|
+
INSERT INTO outbox (entity_type, entity_id, event_type, payload)
|
|
92
|
+
VALUES ('user', '42', 'created', '{"name":"Alice"}'::jsonb);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The handler receives the row and saves a durable checkpoint. On restart, it resumes from that checkpoint. No data loss.
|
|
96
|
+
|
|
97
|
+
See [**Examples**](https://github.com/mochams/walbox/tree/main/examples) for working patterns: publishing to a message broker, writing to a PostgreSQL sink with exactly-once effects, sharded concurrent handling, and metrics.
|
|
98
|
+
|
|
99
|
+
## Next steps
|
|
100
|
+
|
|
101
|
+
- **[Quickstart](https://mochams.github.io/walbox/getting-started/quickstart/)** (5 minutes): step-by-step setup
|
|
102
|
+
- **[Getting Started](https://mochams.github.io/walbox/getting-started/introduction/)**: concepts and guarantees
|
|
103
|
+
- **[Production Guide](https://mochams.github.io/walbox/production/architecture/)**: deployment, monitoring, configuration
|
|
104
|
+
|
|
105
|
+
## Status
|
|
106
|
+
|
|
107
|
+
walbox is at v1.0.0. It has 100% branch coverage, integration tests against real PostgreSQL, and went through three pre-release cycles (beta.1, beta.2, rc.1) to settle the API.
|
|
108
|
+
|
|
109
|
+
See [`CHANGELOG.md`](CHANGELOG.md) for what's changed release to release, and the [Upgrading guide](https://mochams.github.io/walbox/migration/) if you're on a pre-1.0.0 version.
|
|
110
|
+
|
|
111
|
+
## API Stability
|
|
112
|
+
|
|
113
|
+
As of v1.0.0, the following are stable and won't break within the 1.0.x series:
|
|
114
|
+
|
|
115
|
+
- `Walbox` (`build`, `build_with_pool`)
|
|
116
|
+
- `Client`
|
|
117
|
+
- `WalboxOptions`
|
|
118
|
+
- `ConnectionPool`
|
|
119
|
+
- `Transaction`
|
|
120
|
+
- `ChangeEvent`, `ChangeKind`
|
|
121
|
+
- `CheckpointHandle`
|
|
122
|
+
- `Metrics`, `MetricsCallback`
|
|
123
|
+
- `WalboxError` and its subclasses
|
|
124
|
+
|
|
125
|
+
`walbox.abc` and `walbox.checkpoint` expose the underlying protocols and the PostgreSQL checkpoint store, for advanced use like manual `Client` construction or a custom `CheckpointStore`. These are lower-level and may change shape in a minor release.
|
|
126
|
+
|
|
127
|
+
1.0.x releases can add fields or methods, but won't remove or change the meaning of anything listed above.
|
|
128
|
+
|
|
129
|
+
**Development**: see [`CONTRIBUTING.md`](CONTRIBUTING.md) for setup and [`LICENSE`](LICENSE) for terms.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.11.0,<0.13.0"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "walbox"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Async PostgreSQL logical-replication runtime for the transactional outbox pattern"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.13"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = [
|
|
14
|
+
"postgresql",
|
|
15
|
+
"logical-replication",
|
|
16
|
+
"outbox",
|
|
17
|
+
"asyncio",
|
|
18
|
+
"cdc",
|
|
19
|
+
"change-data-capture",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 5 - Production/Stable",
|
|
23
|
+
"Environment :: Console",
|
|
24
|
+
"Framework :: AsyncIO",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Programming Language :: Python :: 3.14",
|
|
30
|
+
"Topic :: Database",
|
|
31
|
+
"Typing :: Typed",
|
|
32
|
+
]
|
|
33
|
+
dependencies = ["psycopg>=3.0,<4"]
|
|
34
|
+
|
|
35
|
+
[[project.authors]]
|
|
36
|
+
name = "Mochama Adriano"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/mochams/walbox"
|
|
40
|
+
Documentation = "https://mochams.github.io/walbox/"
|
|
41
|
+
Repository = "https://github.com/mochams/walbox"
|
|
42
|
+
Issues = "https://github.com/mochams/walbox/issues"
|
|
43
|
+
Author = "https://github.com/mochams"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"cryptography>=50.0.0",
|
|
48
|
+
"mkdocs==1.6.1",
|
|
49
|
+
"mkdocs-material==9.7.7",
|
|
50
|
+
"prek>=0.4.13",
|
|
51
|
+
"psycopg-pool>=3.3.1",
|
|
52
|
+
"psycopg[binary]>=3.2",
|
|
53
|
+
"pylinkvalidator==0.3",
|
|
54
|
+
"pyrefly>=1.2.0",
|
|
55
|
+
"pytest>=9.1.1",
|
|
56
|
+
"pytest-asyncio>=1.4.0",
|
|
57
|
+
"pytest-cov>=7.1.0",
|
|
58
|
+
"pytest-timeout>=2.4.0",
|
|
59
|
+
"pytest-xdist>=3.8.0",
|
|
60
|
+
"ruff>=0.16.1",
|
|
61
|
+
"testcontainers[postgres]>=4.15",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.uv.build-backend]
|
|
65
|
+
module-name = "walbox"
|
|
66
|
+
module-root = "."
|
|
67
|
+
|
|
68
|
+
[tool.ruff]
|
|
69
|
+
extend-exclude = [
|
|
70
|
+
"docs",
|
|
71
|
+
"pages",
|
|
72
|
+
]
|
|
73
|
+
line-length = 88
|
|
74
|
+
indent-width = 4
|
|
75
|
+
target-version = "py313"
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint]
|
|
78
|
+
preview = true
|
|
79
|
+
select = ["ALL"]
|
|
80
|
+
ignore = [
|
|
81
|
+
"assert",
|
|
82
|
+
"mutable-class-default",
|
|
83
|
+
"collapsible-if",
|
|
84
|
+
"missing-copyright-notice",
|
|
85
|
+
"missing-return-type-undocumented-public-function",
|
|
86
|
+
"missing-return-type-private-function",
|
|
87
|
+
"no-self-use",
|
|
88
|
+
"unused-method-argument",
|
|
89
|
+
"undefined-local-with-import-star-usage",
|
|
90
|
+
"class-as-data-structure",
|
|
91
|
+
]
|
|
92
|
+
exclude = ["tests/*.py"]
|
|
93
|
+
fixable = ["ALL"]
|
|
94
|
+
unfixable = []
|
|
95
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
96
|
+
|
|
97
|
+
[tool.ruff.lint.isort]
|
|
98
|
+
force-single-line = true
|
|
99
|
+
case-sensitive = true
|
|
100
|
+
|
|
101
|
+
[tool.ruff.lint.pydocstyle]
|
|
102
|
+
convention = "google"
|
|
103
|
+
|
|
104
|
+
[tool.ruff.lint.pylint]
|
|
105
|
+
max-args = 7
|
|
106
|
+
|
|
107
|
+
[tool.ruff.format]
|
|
108
|
+
preview = true
|
|
109
|
+
exclude = [
|
|
110
|
+
"COM812",
|
|
111
|
+
"ISC001",
|
|
112
|
+
]
|
|
113
|
+
quote-style = "double"
|
|
114
|
+
indent-style = "space"
|
|
115
|
+
skip-magic-trailing-comma = false
|
|
116
|
+
line-ending = "auto"
|
|
117
|
+
docstring-code-format = true
|
|
118
|
+
docstring-code-line-length = 88
|
|
119
|
+
|
|
120
|
+
[tool.pyrefly]
|
|
121
|
+
min-severity = "warn"
|
|
122
|
+
project-excludes = [
|
|
123
|
+
"tests",
|
|
124
|
+
"docs",
|
|
125
|
+
"examples",
|
|
126
|
+
"pages",
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
[tool.pytest.ini_options]
|
|
130
|
+
asyncio_mode = "auto"
|
|
131
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
132
|
+
addopts = [
|
|
133
|
+
"--strict-markers",
|
|
134
|
+
"--cov=walbox",
|
|
135
|
+
"--cov-fail-under=100",
|
|
136
|
+
"--cov-report=term-missing",
|
|
137
|
+
"--durations=10",
|
|
138
|
+
"--timeout=10",
|
|
139
|
+
"-n 0",
|
|
140
|
+
]
|
|
141
|
+
testpaths = ["tests"]
|
|
142
|
+
markers = ["postgres: requires a real PostgreSQL instance, started via testcontainers (make test-integration)"]
|
|
143
|
+
log_cli = "false"
|
|
144
|
+
log_cli_level = "ERROR"
|
|
145
|
+
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
|
|
146
|
+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
147
|
+
|
|
148
|
+
[tool.coverage.run]
|
|
149
|
+
branch = true
|
|
150
|
+
disable_warnings = [
|
|
151
|
+
"include-ignored",
|
|
152
|
+
"no-data-collected",
|
|
153
|
+
]
|
|
154
|
+
parallel = true
|
|
155
|
+
concurrency = [
|
|
156
|
+
"multiprocessing",
|
|
157
|
+
"thread",
|
|
158
|
+
]
|
|
159
|
+
|
|
160
|
+
[tool.coverage.report]
|
|
161
|
+
exclude_also = [
|
|
162
|
+
"def __repr__",
|
|
163
|
+
"def __str__",
|
|
164
|
+
'if self\.debug',
|
|
165
|
+
"raise AssertionError",
|
|
166
|
+
"raise NotImplementedError",
|
|
167
|
+
"if 0:",
|
|
168
|
+
"if __name__ == .__main__.:",
|
|
169
|
+
'@(abc\.)?abstractmethod',
|
|
170
|
+
'^\s*\.\.\.$',
|
|
171
|
+
"if TYPE_CHECKING:",
|
|
172
|
+
]
|
|
173
|
+
skip_covered = "true"
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.11.0,<0.13.0"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "walbox"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Async PostgreSQL logical-replication runtime for the transactional outbox pattern"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.13"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Mochama Adriano" }]
|
|
14
|
+
keywords = [
|
|
15
|
+
"postgresql",
|
|
16
|
+
"logical-replication",
|
|
17
|
+
"outbox",
|
|
18
|
+
"asyncio",
|
|
19
|
+
"cdc",
|
|
20
|
+
"change-data-capture",
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
"Development Status :: 5 - Production/Stable",
|
|
24
|
+
"Environment :: Console",
|
|
25
|
+
"Framework :: AsyncIO",
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Programming Language :: Python :: 3.14",
|
|
31
|
+
"Topic :: Database",
|
|
32
|
+
"Typing :: Typed",
|
|
33
|
+
]
|
|
34
|
+
dependencies = ["psycopg>=3.0,<4"]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/mochams/walbox"
|
|
38
|
+
Documentation = "https://mochams.github.io/walbox/"
|
|
39
|
+
Repository = "https://github.com/mochams/walbox"
|
|
40
|
+
Issues = "https://github.com/mochams/walbox/issues"
|
|
41
|
+
Author = "https://github.com/mochams"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
[dependency-groups]
|
|
45
|
+
dev = [
|
|
46
|
+
"cryptography>=50.0.0",
|
|
47
|
+
"mkdocs==1.6.1",
|
|
48
|
+
"mkdocs-material==9.7.7",
|
|
49
|
+
"prek>=0.4.13",
|
|
50
|
+
"psycopg-pool>=3.3.1",
|
|
51
|
+
"psycopg[binary]>=3.2",
|
|
52
|
+
"pylinkvalidator==0.3",
|
|
53
|
+
"pyrefly>=1.2.0",
|
|
54
|
+
"pytest>=9.1.1",
|
|
55
|
+
"pytest-asyncio>=1.4.0",
|
|
56
|
+
"pytest-cov>=7.1.0",
|
|
57
|
+
"pytest-timeout>=2.4.0",
|
|
58
|
+
"pytest-xdist>=3.8.0",
|
|
59
|
+
"ruff>=0.16.1",
|
|
60
|
+
"testcontainers[postgres]>=4.15",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.uv.build-backend]
|
|
64
|
+
module-name = "walbox"
|
|
65
|
+
module-root = "."
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# ==== Ruff ====
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
# Exclude a variety of commonly ignored directories.
|
|
71
|
+
extend-exclude = ["docs", "pages"]
|
|
72
|
+
|
|
73
|
+
# Python line length and indent width
|
|
74
|
+
line-length = 88
|
|
75
|
+
indent-width = 4
|
|
76
|
+
|
|
77
|
+
# Assume Python 3.13
|
|
78
|
+
target-version = "py313"
|
|
79
|
+
|
|
80
|
+
[tool.ruff.lint]
|
|
81
|
+
# Enable opt-in preview mode
|
|
82
|
+
preview = true
|
|
83
|
+
|
|
84
|
+
# Enable rules
|
|
85
|
+
select = ['ALL']
|
|
86
|
+
ignore = [
|
|
87
|
+
"assert", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/
|
|
88
|
+
"mutable-class-default", # Mutable class attributes should be annotated with `typing.ClassVar`
|
|
89
|
+
"collapsible-if", # Sometimes it's better to nest
|
|
90
|
+
"missing-copyright-notice", # Copyright
|
|
91
|
+
"missing-return-type-undocumented-public-function", # Return type annotation
|
|
92
|
+
"missing-return-type-private-function", # Return type annotation (private)
|
|
93
|
+
"no-self-use", # Sometimes it is possible i.e interface methods
|
|
94
|
+
"unused-method-argument", # Sometimes it is possible i.e interface methods
|
|
95
|
+
"undefined-local-with-import-star-usage",
|
|
96
|
+
"class-as-data-structure",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
# Exclude for tests
|
|
100
|
+
exclude = ["tests/*.py"]
|
|
101
|
+
|
|
102
|
+
# Allow fix for all enabled rules (when `--fix`) is provided.
|
|
103
|
+
fixable = ["ALL"]
|
|
104
|
+
unfixable = []
|
|
105
|
+
|
|
106
|
+
# Allow unused variables when underscore-prefixed.
|
|
107
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
108
|
+
|
|
109
|
+
[tool.ruff.format]
|
|
110
|
+
# Enable opt-in preview mode
|
|
111
|
+
preview = true
|
|
112
|
+
|
|
113
|
+
# Ignore
|
|
114
|
+
exclude = ["COM812", "ISC001"]
|
|
115
|
+
|
|
116
|
+
# Like Black, use double quotes for strings.
|
|
117
|
+
quote-style = "double"
|
|
118
|
+
|
|
119
|
+
# Like Black, indent with spaces, rather than tabs.
|
|
120
|
+
indent-style = "space"
|
|
121
|
+
|
|
122
|
+
# Like Black, respect magic trailing commas.
|
|
123
|
+
skip-magic-trailing-comma = false
|
|
124
|
+
|
|
125
|
+
# Like Black, automatically detect the appropriate line ending.
|
|
126
|
+
line-ending = "auto"
|
|
127
|
+
|
|
128
|
+
# Enable auto-formatting of code examples in docstrings.
|
|
129
|
+
docstring-code-format = true
|
|
130
|
+
|
|
131
|
+
# Set the line length limit used when formatting code snippets in
|
|
132
|
+
# docstrings.
|
|
133
|
+
docstring-code-line-length = 88
|
|
134
|
+
|
|
135
|
+
[tool.ruff.lint.isort]
|
|
136
|
+
# Forces all from imports to appear on their own line.
|
|
137
|
+
force-single-line = true
|
|
138
|
+
|
|
139
|
+
# Sort imports in a case-sensitive manner.
|
|
140
|
+
case-sensitive = true
|
|
141
|
+
|
|
142
|
+
[tool.ruff.lint.pydocstyle]
|
|
143
|
+
# Whether to use Google-style, NumPy-style conventions, or the PEP 257 default.
|
|
144
|
+
convention = "google"
|
|
145
|
+
|
|
146
|
+
[tool.ruff.lint.pylint]
|
|
147
|
+
# Maximum number of arguments allowed for a function or method definition
|
|
148
|
+
max-args = 7
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# === Pyrefly ===
|
|
152
|
+
[tool.pyrefly]
|
|
153
|
+
min-severity = "warn"
|
|
154
|
+
project-excludes = ["tests", "docs", "examples", "pages"]
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# === Pytest ===
|
|
158
|
+
[tool.pytest.ini_options]
|
|
159
|
+
asyncio_mode = "auto"
|
|
160
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
161
|
+
addopts = [
|
|
162
|
+
"--strict-markers",
|
|
163
|
+
"--cov=walbox",
|
|
164
|
+
"--cov-fail-under=100",
|
|
165
|
+
"--cov-report=term-missing",
|
|
166
|
+
"--durations=10",
|
|
167
|
+
"--timeout=10",
|
|
168
|
+
"-n 0",
|
|
169
|
+
]
|
|
170
|
+
testpaths = ["tests"]
|
|
171
|
+
markers = [
|
|
172
|
+
"postgres: requires a real PostgreSQL instance, started via testcontainers (make test-integration)",
|
|
173
|
+
]
|
|
174
|
+
log_cli = "false"
|
|
175
|
+
log_cli_level = "ERROR"
|
|
176
|
+
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
|
|
177
|
+
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
# ==== Coverage ====
|
|
181
|
+
[tool.coverage.run]
|
|
182
|
+
branch = true
|
|
183
|
+
disable_warnings = ["include-ignored", "no-data-collected"]
|
|
184
|
+
|
|
185
|
+
parallel = true
|
|
186
|
+
concurrency = ["multiprocessing", "thread"]
|
|
187
|
+
|
|
188
|
+
[tool.coverage.report]
|
|
189
|
+
exclude_also = [
|
|
190
|
+
# Don't complain about missing debug-only code:
|
|
191
|
+
"def __repr__",
|
|
192
|
+
"def __str__",
|
|
193
|
+
"if self\\.debug",
|
|
194
|
+
# Don't complain if tests don't hit defensive assertion code:
|
|
195
|
+
"raise AssertionError",
|
|
196
|
+
"raise NotImplementedError",
|
|
197
|
+
# Don't complain if non-runnable code isn't run:
|
|
198
|
+
"if 0:",
|
|
199
|
+
"if __name__ == .__main__.:",
|
|
200
|
+
# Don't complain about abstract methods, they aren't run:
|
|
201
|
+
"@(abc\\.)?abstractmethod",
|
|
202
|
+
# Exclude protocol methods implementations i.e '...', they aren't run:
|
|
203
|
+
"^\\s*\\.\\.\\.$",
|
|
204
|
+
# Exclude TYPE_CHECKING blocks
|
|
205
|
+
"if TYPE_CHECKING:",
|
|
206
|
+
]
|
|
207
|
+
skip_covered = "true"
|