lukashes/outboxx
Outboxx - Lightweight PostgreSQL Change Data Capture in Zig
master463f8d5349daf72430697c9fe42cfe0a68729859.tar.gzPostgreSQL Change Data Capture in Zig
Lightweight tool that streams WAL changes to Kafka. Built in Zig for minimal resource consumption.
🚀 Development Status: Core CDC pipeline implemented with streaming replication. Under active optimization, approaching alpha release.
Outboxx captures PostgreSQL database changes in real-time and streams them to Kafka topics. Inspired by Debezium but designed for simplicity and low resource usage.
Key Features:
| Component | Status |
|---|---|
| PostgreSQL Streaming Replication | ✅ Working |
| Message Processing | ✅ Working |
| Kafka Producer | ✅ Working |
| TOML Configuration | ✅ Working |
| Multi-stream Support | ✅ Working |
| Schema Registry | 📋 Planned |
| Table/Column Filtering | 📋 Planned |
| Production Features | 📋 Planned |
Outboxx is heavily inspired by Debezium, the industry standard for Change Data Capture. Debezium is an excellent, battle-tested solution with a rich feature set. However, being a JVM-based application, it comes with resource overhead that may not be suitable for all environments:
| Aspect | Outboxx | Debezium |
|---|---|---|
| Runtime | Native binary | JVM (Kafka Connect) |
| Memory Usage | <10 MB | ~200-500 MB |
| Startup Time | <1s | 10-30s |
| Throughput | ~105k events/sec | ~150k events/sec |
| Configuration | Simple TOML | Complex JSON/Properties |
| Deployment | Single binary | Kafka Connect cluster |
Choose Outboxx when:
Stick with Debezium when:
Outboxx aims to bring Debezium's excellent CDC concepts to resource-constrained environments where every MB of RAM matters.
[metadata]
version = "v0"
[source]
type = "postgres"
[source.postgres]
host = "localhost"
port = 5432
database = "mydb"
user = "postgres"
password_env = "POSTGRES_PASSWORD"
slot_name = "outboxx_slot"
publication_name = "outboxx_publication"
[sink]
type = "kafka"
[sink.kafka]
brokers = ["localhost:9092"]
# Multiple streams for different tables
[[streams]]
name = "users-stream"
[streams.source]
resource = "users"
operations = ["insert", "update", "delete"]
[streams.flow]
format = "json"
[streams.sink]
destination = "user_changes"
[[streams]]
name = "orders-stream"
[streams.source]
resource = "orders"
operations = ["insert", "update"]
[streams.flow]
format = "json"
[streams.sink]
destination = "order_changes"
For complete configuration examples and architectural documentation, see docs/examples/config.toml.
PostgreSQL Requirements: Version 14 or later (tested and supported versions)
Configure PostgreSQL (postgresql.conf):
wal_level = logical # Required for logical replication (CDC)
Restart PostgreSQL after configuration changes.
Create User (run as PostgreSQL superuser):
-- Create user with REPLICATION attribute (required for replication slots and WAL access)
CREATE USER outboxx_user WITH REPLICATION PASSWORD 'secure_password';
-- Grant database access
GRANT CONNECT ON DATABASE my_database TO outboxx_user;
-- Grant schema access (CREATE needed for creating publications)
GRANT USAGE, CREATE ON SCHEMA public TO outboxx_user;
-- Grant table access (SELECT needed for logical replication)
GRANT SELECT ON TABLE my_table TO outboxx_user;
-- Enable REPLICA IDENTITY FULL (required for capturing complete row data in UPDATE/DELETE)
ALTER TABLE my_table REPLICA IDENTITY FULL;
Note: Outboxx automatically creates replication slot and publication on startup. Currently supports public schema only.
Kafka Setup:
auto.create.topics.enable=true)# Build the application
make build
# Run with your configuration
export POSTGRES_PASSWORD="your_password"
./zig-out/bin/outboxx --config config.toml
⚠️ Outboxx requires a process supervisor (systemd, Kubernetes, Docker restart policy, supervisord) as it uses fail-fast error handling. PostgreSQL replication slots preserve state across restarts.
This is a learning project for Zig programming. See dev/README.md for development setup.
For complete configuration examples and design vision, see docs/examples/.
MIT License - See LICENSE file for details.