Nginx event loop
HTTP, WebSockets, and nonblocking database I/O share Nginx’s event loop.
SQL-first backend Alpha
A Rust module for Nginx that exposes PostgreSQL functions over HTTP and delivers change notifications over WebSockets.
Get startedHTTP, WebSockets, and nonblocking database I/O share Nginx’s event loop.
Prepared statements and pipelining reduce repeated work and database round trips.
PostgreSQL’s JSONB response text passes through unchanged. Disabling output validation also avoids response JSON parsing.
The patched-libpq build eliminates request-body copies into Rust and libpq for eligible requests. Automatic borrowing applies to qualifying large requests over plaintext database connections. Standard builds retain copying.
The benchmark above used copied buffers. Responses and TLS still involve copies.
# HTTP endpoints
pgxio_endpoint list_tasks
web.list_tasks read_only;
pgxio_endpoint create_task
web.create_task;
# WebSocket subscription authorization
pgxio_stream tasks
web.authorize_tasks;SQL functions accept and return JSON. They handle queries, business rules, and authorization.
Declare the functions your API exposes. pgxio checks JWTs and calls each function inside a transaction.
Authorized WebSocket subscriptions signal changes. Your client refetches the current snapshot over HTTP.
Subscriptions deliver change signals, not a durable event log. On reconnect, clients resubscribe and fetch a fresh snapshot.
Run these commands from an existing pgxio checkout. You’ll need Docker Compose and Python 3.9 or newer.
The included development stack binds to localhost. pgxio is alpha software; this configuration is for local exploration.
bin/pgxio init
bin/pgxio up
TOKEN=$(bin/pgxio token alice)
curl http://localhost:8080/v1/create_task \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"title":"Hello from pgxio"}'
curl http://localhost:8080/v1/list_tasks \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{}'