Building & Testing¶
The entire build, test, and documentation pipeline is fully containerized with Docker so you don't need local Rust, cargo-pgrx, PostgreSQL 15 headers, Go, or JDK toolchains installed.
One-Command Full Verification¶
Run the master end-to-end test harness:
This script verifies all RFC acceptance criteria in sequence:
- Runtime Docker Build (
docker/Dockerfileruntimetarget): Compilespg_redis_corewithcargo pgrx package(PG_MAJOR=15or16) and installs the.so,.control, and generated.sqlintopostgres:${PG_MAJOR}-bookworm. - Raw TCP RESP Compliance (
tests/raw_resp_test.sh): Validates*1\r\n$4\r\nPING\r\n->+PONG\r\n, inlinePING, pipelined multi-command bursts, and RESP3HELLO 3. - Python Integration Suite (
test-python): Runspytestcovering FastAPI gateway endpoints, binary-safe Strings, TTL expiration +pg_redis_evict_expired(), Hashes, Lists, Sorted Sets, pipelining, L1 cache hits, and direct PostgreSQL table parity viapsycopg. - Go Integration Suite (
test-go): Runsgo-redis/v9with default RESP3 negotiation across all data types,ZRangeWithScores,Pipeline, andTxPipeline. - Kotlin Integration Suite (
test-kotlin): RunsJedis 5.2.0across Strings, Counters, Hashes, Lists, Sorted Sets, and pipelining. - BullMQ 5.13.0 Suite (
test-bullmq): Runs unmodifiedbullmq@5.13.0covering Lua 5.1 (EVAL/EVALSHA/SCRIPT LOAD/cjson/cmsgpack), Streams (XADD/XREAD BLOCK), and cooperativeBZPOPMIN. - Pub/Sub & v0.4.0 Suite (
test-pubsub): Runsioredis@5.11.1+bullmq@5.13.0covering named & pattern Pub/Sub (SUBSCRIBE/PSUBSCRIBE/PUBSUB), universal TTL across all 6 data types (NX|XX|GT|LT,GETEX),HSCAN/SSCAN/ZSCAN/SCAN TYPE, multi-clientCLIENT LIST/KILL, BullMQFlowProducergetDependencies()&getWorkers(), and Lua sandbox verification. - v0.4.0 Security & Limits Suite (
./tests/test_v040_security.sh): Verifiespg_redis.requirepass(NOAUTH/WRONGPASS/AUTH/HELLO AUTH/RESET),pg_redis.lua_time_limit_msrunaway script termination,pg_redis.max_clients, andpg_redis.max_frame_bytes. - PostgreSQL 15 & 16 DB Isolation Suite (
./tests/test_solar_nest_isolation.sh 15 16): Exercises both PG 15 and PG 16 withpg_redis.database=solar_nest_rediskept isolated from application DBsolar_nestalongsidetest-pubsubandtest-bullmq. - In-PostgreSQL
pgrxUnit Tests &cargo pgrx run(devtarget): Runscargo pgrx test pg15/pg16(all 11#[pg_test]cases) and smoke-testscargo pgrx run.
Running cargo pgrx Directly via Docker¶
# Build the dev image with Rust, cargo-pgrx 0.11.4, and PG15 headers (pass --build-arg PG_MAJOR=16 for PG16)
docker build --target dev -f docker/Dockerfile -t pg_redis_core:dev .
# Run in-PostgreSQL Rust unit tests (PG15)
docker run --rm pg_redis_core:dev cargo pgrx test pg15
# Or build & test against PostgreSQL 16
docker build --target dev --build-arg PG_MAJOR=16 -f docker/Dockerfile -t pg_redis_core:dev-pg16 .
docker run --rm pg_redis_core:dev-pg16 cargo pgrx test pg16 --no-default-features --features pg16
# Launch an interactive psql session via cargo pgrx run pg15
docker run --rm -it pg_redis_core:dev cargo pgrx run pg15
Previewing Documentation Locally¶
Serve this MkDocs Material site with live reload on http://localhost:8080:
Or run a strict production build check:
Branching & GitHub Actions Release Workflow¶
All changes follow a branch-and-PR workflow into main:
- Create a feature branch from
main: - Commit changes, push the branch, and open a Pull Request against
main. - GitHub Actions CI (
.github/workflows/ci.yml) validatesmkdocs build --strictand the full Dockerized integration +cargo pgrx test pg15suite before merge. - To cut a release (
vX.Y.Z): - Bump
versioninCargo.toml, add asql/pg_redis_core--<prev>--<next>.sqlupgrade script, and updateCHANGELOG.mdin your PR. - Merge the PR into
main. Once CI (.github/workflows/ci.yml) passes onmain, Release (.github/workflows/release.yml) automatically triggers viaworkflow_run:- If tag
vX.Y.Zalready exists onorigin, it skips cleanly (so docs/CI-only merges never create duplicate releases). - If tag
vX.Y.Zis new, it natively builds & smoke-testslinux/amd64andlinux/arm64extension tarballs for both PostgreSQL 15 and PostgreSQL 16, publishes multi-arch Docker images (:vX.Y.Z-pg15,:vX.Y.Z-pg16, and:vX.Y.Z) toghcr.io/megacoderkim/pg2redis, pushes annotated tagvX.Y.Zon the tested commit, and publishes the GitHub Release withSHA256SUMS.txt.
- If tag
- Manual tag pushes (
git tag -a vX.Y.Z && git push origin vX.Y.Z) andworkflow_dispatchremain supported as fallbacks.
Project Layout¶
pg2redis/
├── Cargo.toml # Rust crate manifest (pgrx 0.11.4, tokio, redis-protocol 6.0, mlua 0.10, moka)
├── pg_redis_core.control # PostgreSQL extension control file
├── mkdocs.yml # Material for MkDocs configuration
├── docker-compose.yml # pg-redis, fastapi-gateway, test runners, and docs preview
├── .github/workflows/
│ ├── ci.yml # MkDocs strict check + full Dockerized & PG 15/16 CI suite
│ ├── release.yml # Auto-release on main after CI passes (PG15/PG16 amd64/arm64 + GHCR)
│ └── docs.yml # GitHub Pages MkDocs Material deployment
├── docker/
│ ├── Dockerfile # Multi-stage PG15/PG16 builder, dev (pgrx test/run), and runtime targets
│ ├── Dockerfile.docs # MkDocs Material build/preview container
│ ├── init.sql # CREATE EXTENSION IF NOT EXISTS pg_redis_core;
│ └── postgresql.conf # Reference PostgreSQL + pg_redis.* GUC configuration
├── sql/ # Incremental PostgreSQL extension upgrade scripts (0.1.0 -> 0.4.1)
├── src/
│ ├── lib.rs # extension_sql!, _PG_init, redis_dispatcher, SQL helpers, #[pg_test]
│ ├── config.rs # PostgreSQL GUC definitions (pg_redis.* + constant-time AUTH compare)
│ ├── cache.rs # In-process moka L1 hot-key cache
│ ├── clients.rs # Live multi-connection ClientRegistry (CLIENT LIST/INFO/KILL, INFO)
│ ├── lua.rs # Sandboxed Lua 5.1 VM (mlua) with timeout hook, cjson, cmsgpack, bit
│ ├── notify.rs # Per-key cooperative async KeyNotifier (BZPOPMIN, BLPOP, XREAD BLOCK)
│ ├── protocol.rs # Zero-copy RESP2/RESP3 codec (redis-protocol 6.0)
│ ├── pubsub.rs # In-process named & pattern PubSubHub with bounded slow-consumer queues
│ ├── storage.rs # 7-table catalog DDL, SPI PreparedPlans, universal ctid TTL eviction
│ ├── worker.rs # BGWorker + Tokio current_thread/LocalSet TCP listener & limits
│ └── commands/ # Command handlers (strings, keys, hashes, lists, zsets, sets, streams, server)
├── docs/ # MkDocs Material documentation source
└── tests/
├── raw_resp_test.sh # Raw TCP RESP2/RESP3 verification
├── test_v040_security.sh # AUTH/requirepass, Lua timeout, max_clients & max_frame_bytes tests
├── test_solar_nest_isolation.sh # PG 15 & 16 isolated-DB + Pub/Sub + BullMQ suite
├── run_all_tests.sh # Master end-to-end verification runner
└── clients/
├── bullmq/ # Unmodified bullmq@5.13.0 integration suite
├── pubsub/ # ioredis@5.11.1 Pub/Sub, v0.4.0 features & security tests
├── python/ # FastAPI gateway + redis-py + psycopg pytest suite
├── kotlin/ # Jedis 5.2.0 Gradle project
└── go/ # go-redis/v9 RESP3 Go module