outbox-streaming
Reliably send messages to message/task brokers, like Kafka or Celery
Roadmap
Done
- ✅ Kafka + SQLAlchemy
- ✅ Kafka + SQLAlchemy + asyncio
In progress
- ⏹ Celery + SQLAlchemy
- ⏹ Celery + SQLAlchemy + asyncio
Planned
- 🆕 Kafka + Django ORM
- 🆕 Celery + Django ORM
- 🆕 Dramatiq + SQLAlchemy
- 🆕 Dramatiq + SQLAlchemy + asyncio
- 🆕 Dramatiq + Django
- 🆕 RabbitMQ + SQLAlchemy
- 🆕 RabbitMQ + SQLAlchemy + asyncio
- 🆕 RabbitMQ + Djagno
Example FastAPI + Kafka + SQLAlchemy
from fastapi import FastAPI
from outbox_streaming.kafka.sqlalchemy import SQLAlchemyKafkaOutbox
from sqlalchemy import orm
from app import models, db
from app.config import config
from app.schemas import TodoCreate
app = FastAPI()
# create instance of SQLAlchemyKafkaOutbox
outbox = SQLAlchemyKafkaOutbox(
engine=db.engine,
kafka_servers=config.KAFKA_SERVERS,
)
# Run separate tread that monitor outbox table and publish messages to Kafka. It's not recommended for production,
# but it's handy for development
outbox.publisher.run_daemon()
Session = orm.sessionmaker(bind=db.engine)
# create outbox tables
outbox.storage.create_tables(engine=db.engine)
@app.post('/todos')
def create_todo(create: TodoCreate) -> str:
with Session() as session:
# create new object
todo = models.Todo(text=create.text)
session.add(todo)
# create kafka event in outbox table
outbox.save(
session=session,
topic='todo_created',
value=todo.to_dict(),
)
# commit changes in database
session.commit()
# publisher will pick up kafka message from outbox table and will send it kafka topic
return "OK"
Metadata
Release files for outbox-streaming 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| outbox-streaming-0.1.0.tar.gz | 16.1 kB | Without provenance | Details for outbox-streaming-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| outbox_streaming-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for outbox_streaming-0.1.0-py3-none-any.whl |
Total release size: 35.2 kB
Release files / outbox-streaming-0.1.0.tar.gz
| Download URL | outbox-streaming-0.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7ea981203f968f64c051c84251bd63ed0f6ac2a4f43fa6a7277f5ca1e7b8b22
|
|
BLAKE2b-256 checksum How to use checksums |
3e35e04c0bbe2473bb22fc0a7b6b620b4f1fee873f816e7aae5d474508981c10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.1 Darwin/21.5.0
|
Release files / outbox_streaming-0.1.0-py3-none-any.whl
| Download URL | outbox_streaming-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f6ac749ac42dc20a82369a194e92cbd8f6dfe3f983045c0593af4b92d0b4a6b
|
|
BLAKE2b-256 checksum How to use checksums |
03764ba4f584fddf445c4a49b44f5173a1c8d84d535b57d3e5a2f69adcdf49d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.1 Darwin/21.5.0
|
Security for outbox-streaming 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.