Guides
Enable the feature:
cargo add pglite-rs --features multiple-process
Open:
use pglite::{MultiProcessOptions, PGlite};
let db = PGlite::open_multi_process("./data", MultiProcessOptions::default()).await?;
Multi-process mode extracts the bundled runtime, initializes the
data directory, starts bin/postgres with
listen_addresses= and a private Unix socket, then
creates a connection pool behind the same PGlite API.
Multi-process
PGlite API
query/exec/transaction
Pool
min/max idle connections
Child postmaster
private Unix socket, no TCP listen
Options
| Field | Default | Purpose |
|---|---|---|
username |
postgres |
Startup user. |
database |
postgres |
Startup database. |
min_connections |
0 |
Minimum pooled connections. |
max_connections |
5 |
Maximum pooled API connections. |
extra_connections |
4 |
Extra postmaster slots for external clients. |
idle_ttl |
300s |
Idle pooled connection lifetime. |
relaxed_durability |
false |
Adds fsync=off. |
start_params |
[] |
Extra -c name=value postmaster params. |
locale_provider |
Libc |
Initdb locale provider. |
Connection URI
let uri = db.connection_uri().unwrap();
let socket = db.socket_path().unwrap();
unix_uri() also returns this URI when
socket is enabled.
