Comment on page

Getting started

Speculare PGCDC is used to stream change from the Postgres database over WebSocket to active clients.


As of now Speculare PGCDC does not provide easy setup solution such as a one-line installer (but it's planned). The current recommanded way to install Speculare PGCDC is to build it from source. But don't be afraid, it's easy and straightforwards.

Install dependencies

Speculare PGCDC is a Rust project that rely on some dependencies to be able to be built correctly. Much of them are default deps in most servers.
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf | sh
# Install APT dependencies
sudo apt-get install libssl-dev libpq-dev pkg-config build-essential

Configuration files

The server binary depends on a Pgcdc.toml file whose path will be passed as arguments to the binary.
You can create your Pgcdc.toml from the Pgcdc.example.toml given in the source code or using the following template:
POSTGRES_USER = "postgres"
POSTGRES_PASSWORD = "azertyuiop"
POSTGRES_TLS = false # default = true
KEY_PRIV = "key.pem" # (optional)
KEY_CERT = "cert.pem" # (optional)
HTTPS = true # (optional [default = false])
RUST_LOG = "warn,speculare_pgcdc=info,warp=info" # (optional)
PGCDC will get a list of available tables at startup time. In case of update of the database you might need to restart PGCDC to refetch new tables.

Example of usage

Use this base request:
Will get change_type event from table where col is equals to val. The change_table and table parameters are mandatory, if you're missing them you'll get a 400 error.
  • change_table: can be either of those: *, insert, update, delete
  • table: must be a real table from your database
  • col.eq.val: is optional but col is the column name and val is the expected value (String)

Install as a service

Here is a sample speculare-pgcdc.service for systemd:
Description=Speculare Cdc Process postgresql.service
ExecStart=/root/speculare-pgcdc/target/release/speculare-pgcdc "/path/to/Config.toml"
The above service will start after postgres, this is important. The pgcdc cannot start before postgresql.