Skip to main content

Crate themis_postgres

Crate themis_postgres 

Source
Expand description

Postgres LISTEN/NOTIFY transport for the themis_sync::Hub.

See the repository README for the full guide.

use themis_sync::Hub;
use themis_postgres::PgTransport;

let hub = Hub::builder()
    .transport(PgTransport::new("postgres://app@localhost/app", "themis_changes")?)
    .build();
let _relay = hub.spawn_relay();

§Notifying in the same transaction as the change

NOTIFY is delivered only on commit. Writing the grant and calling notify in the same transaction guarantees that the notice goes out if, and only if, the change was written. A notice sent this way does not go through themis_sync::Hub::publish and arrives without an origin, so the relay delivers it on every instance, including the one that wrote it.

TLS: PgTransport::with_tls accepts any tokio-postgres connector (postgres-native-tls, tokio-postgres-rustls).

Structs§

PgTransport

Constants§

MAX_PAYLOAD
Largest payload pg_notify accepts with the default Postgres configuration.

Functions§

notify
Sends change on the channel through the given client or transaction.