Change Data Capture over Postgres Write-Ahead Log. Streams row-level inserts, updates, and deletes from any np_* table to downstream consumers — webhooks, Redis Streams, or custom event handlers — with at-least-once delivery and a replication slot that survives restarts. Useful for cache invalidation, audit pipelines, real-time dashboards, and syncing Postgres to external systems without polling.
nself plugin install cdc
nself build
nself start| Variable | Required | Default | Description |
|---|---|---|---|
CDC_REPLICATION_SLOT | No | nself_cdc | Postgres logical replication slot name |
CDC_PUBLICATION | No | nself_pub | Postgres publication name — controls which tables are captured |
CDC_TABLES | No | * | Comma-separated table list to capture, or * for all published tables |
CDC_OUTPUT | No | webhook | Output driver: webhook, redis, stdout |
CDC_WEBHOOK_URL | Cond. | — | Target URL when CDC_OUTPUT=webhook |
CDC_WEBHOOK_SECRET | No | — | HMAC-SHA256 signing secret for outbound webhook payloads |
CDC_REDIS_STREAM | Cond. | nself:cdc | Redis Stream key when CDC_OUTPUT=redis |
CDC_BATCH_SIZE | No | 100 | Max events per flush cycle |
CDC_FLUSH_INTERVAL_MS | No | 500 | Flush interval in milliseconds |
CDC_RETRY_MAX | No | 5 | Max delivery retries before the event is moved to the dead-letter table |
# Postgres: create a publication for all tables (or name specific ones)
nself db psql -c "CREATE PUBLICATION nself_pub FOR ALL TABLES;"
# Or limit to specific tables
nself db psql -c "CREATE PUBLICATION nself_pub FOR TABLE np_users, np_orders;"{
"id": "01HX...",
"table": "np_users",
"schema": "public",
"op": "INSERT",
"ts": "2026-05-01T10:00:00.123Z",
"lsn": "0/16C3A28",
"before": null,
"after": {
"id": "user-uuid",
"email": "alice@example.com",
"created_at": "2026-05-01T10:00:00Z"
}
}| Endpoint | Method | Description |
|---|---|---|
/cdc/status | GET | Replication slot lag, LSN position, consumer health |
/cdc/events | GET | Recent captured events with filtering by table and operation |
/cdc/dead-letter | GET | Events that exhausted retries and could not be delivered |
/cdc/dead-letter/:id/retry | POST | Manually re-queue a dead-letter event |
/cdc/health | GET | Liveness check — confirms replication slot is active |
np_cdc_events — recent captured events with delivery statusnp_cdc_dead_letter — events that exceeded the retry limitnp_cdc_cursors — per-consumer LSN checkpoint trackingUndelivered events cause the replication slot to retain WAL segments. If your consumer is down for an extended period, disk usage can grow significantly. Monitor slot lag via /cdc/status and set a max_slot_wal_keep_sizein postgresql.conf to bound WAL retention.
Pro Plugin — ɳSelf+ | v1.0.0