pub struct PgListenerBuilder { /* private fields */ }Expand description
Builder for a PgListener with non-default PgListenerOptions.
Implementations§
Source§impl PgListenerBuilder
impl PgListenerBuilder
Sourcepub fn reconnect(self, reconnect: bool) -> Self
pub fn reconnect(self, reconnect: bool) -> Self
Whether to reconnect after the connection is lost.
Sourcepub fn backoff(self, initial: Duration, max: Duration) -> Self
pub fn backoff(self, initial: Duration, max: Duration) -> Self
Reconnect backoff: the first delay (non-zero) and the upper bound (at
least initial).
Sourcepub fn keepalive_idle(self, idle: Duration) -> Self
pub fn keepalive_idle(self, idle: Duration) -> Self
TCP keepalive idle time on the listener connection (at least 1 s).
Sourcepub fn ping_interval(self, interval: Duration) -> Self
pub fn ping_interval(self, interval: Duration) -> Self
Liveness check period (at least 100 ms, at most one day); see
PgListenerOptions::ping_interval.
Sourcepub fn buffer(self, buffer: usize) -> Self
pub fn buffer(self, buffer: usize) -> Self
Capacity of the notification queue (at least 1, at most tokio’s
Semaphore::MAX_PERMITS); see PgListenerOptions::buffer.
Sourcepub fn max_reconnect_attempts(self, attempts: impl Into<Option<u32>>) -> Self
pub fn max_reconnect_attempts(self, attempts: impl Into<Option<u32>>) -> Self
Give up after attempts failed reconnect attempts in a row (None:
never); see PgListenerOptions::max_reconnect_attempts.
Sourcepub fn options(self, options: PgListenerOptions) -> Self
pub fn options(self, options: PgListenerOptions) -> Self
Replace all options at once.
Sourcepub async fn connect(self) -> PgResult<PgListener>
pub async fn connect(self) -> PgResult<PgListener>
Open the listener connection.
Fails if the options are invalid, the TLS configuration is unusable
(see the pool’s ssl_mode rules), or the connection cannot be
established. The attempt, including the TLS and startup handshake,
is bounded by PgConfig::connect_timeout plus
PgListenerOptions::ping_interval; past that it fails with a
connection error.