Skip to main content

Transactional outbox and inbox primitives for PostgreSQL, on SQLAlchemy.

Project description

pactix

pactix is a Python library for transactional outbox and inbox workflows on PostgreSQL, built on SQLAlchemy (async).

Use it when a service needs to commit business data and outgoing events in the same transaction, store incoming messages before handler execution, and retry failed work safely across multiple workers.

Features

  • Deduplication by source + message_id on the inbox side
  • FIFO within the same event_type + ordering_key
  • Optional unordered inbox processing with a stale-event filter contract
  • Retry scheduling and lease-based recovery for stuck workers
  • Transport-agnostic core protocols
  • Built-in helpers for common hooks, stale-event filters, and closure-based adapters
  • Optional Kafka adapters behind the kafka extra
  • Optional HTTP adapters behind the http extra

If a publisher or handler may run more than once, that is normal. Business effects still need idempotent application logic.

Installation

pip install pactix                 # core (sqlalchemy + asyncpg)
pip install "pactix[kafka]"        # + Kafka transport (aiokafka)
pip install "pactix[http]"         # + HTTP transport (httpx + starlette)
pip install "pactix[migrations]"   # + Alembic for running the migrations

Database setup

pactix does not run migrations for you. Either run the bundled Alembic migrations (src/pactix/db/migrations, see alembic.ini) or copy the table definitions in pactix.db.tables into your own migration system. The library expects two tables: outbox_message and inbox_message.

Documentation

See examples/worker_loop.py for a runnable worker-loop sketch.

Development

make install   # uv sync with all extras
make check     # format + lint + mypy + test

Database-backed tests use testcontainers and require Docker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pactix-0.1.0.tar.gz (89.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pactix-0.1.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

Details for the file pactix-0.1.0.tar.gz.

File metadata

  • Download URL: pactix-0.1.0.tar.gz
  • Upload date:
  • Size: 89.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pactix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4942c8dba65e49e298482f17e94c15c61f1019de3f075697881d9f6ada1cda53
MD5 3c584fec8199738bc8eba5a3a23c2302
BLAKE2b-256 b16a47816747c5d404c884966c337d8a32dc5eb37adb2bd044d9ef6af5c6c8d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pactix-0.1.0.tar.gz:

Publisher: publish.yml on victornguen/pactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pactix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pactix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pactix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9fc1582f26e35291788b4c532c35da5b229d7785653e27dcdb9cb33d5910a1ae
MD5 e5d646473cefc948785b5b9553ebae30
BLAKE2b-256 41bc7bddeae2382a85f83164a01a85c5c9a324d4328627788e4d58fcb2850756

See more details on using hashes here.

Provenance

The following attestation bundles were made for pactix-0.1.0-py3-none-any.whl:

Publisher: publish.yml on victornguen/pactix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page