Skip to main content

PostgresInboxSettings

Struct PostgresInboxSettings 

Source
#[non_exhaustive]
pub struct PostgresInboxSettings { pub schema: String, pub claim_sets_search_path: bool, pub statement_timeout: Duration, pub max_attempts: u32, }
Expand description

What is provider-specific about the inbox (inbox contract §3). A separate settings type from PostgresOutboxSettings — the inbox has no lease/ordering/retention knobs. It does share the outbox’s Self::statement_timeout knob, applied to the same kind of call: every statement the inbox issues on its own pool (fail, find, purge) rather than the caller’s transaction (claim/complete, which stay the caller’s to bound).

Built from Self::default plus builder methods, never a struct literal (#[non_exhaustive] so a new field never breaks a caller outside this crate):

use reliar_store_postgres::PostgresInboxSettings;
use std::time::Duration;

let settings = PostgresInboxSettings::default()
    .schema("orders")
    .claim_sets_search_path(true)
    .statement_timeout(Duration::from_secs(2))
    .max_attempts(5);

assert_eq!(settings.schema, "orders");
assert!(settings.claim_sets_search_path);
assert_eq!(settings.statement_timeout, Duration::from_secs(2));
assert_eq!(settings.max_attempts, 5);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§schema: String

The schema crate::PostgresInboxStore::connect verifies inbox resolves to. SHALL agree with whatever schema migrate() was given — the inbox shares the outbox’s single migrate(), schema and _migrations table (inbox contract §1). SCHEMA. Default "reliar".

§claim_sets_search_path: bool

When true, crate::PostgresInboxStore’s claim and complete wrap their statements in a transaction-local set_config('search_path', …, true) and restore the caller’s previous value afterward — for a caller that overrides search_path inside its own transaction (a host that could change neither the connection URL nor the role would already fail connect’s own search_path verification, so this is not that case). Mirrors PostgresOutboxSettings::enqueue_sets_search_path; defaults to false for the same reason (it costs extra statements on the caller’s own transaction). CLAIM_SETS_SEARCH_PATH.

§statement_timeout: Duration

Applied as SET LOCAL statement_timeout inside the short transaction Reliar opens for every statement it issues on its own poolfail, find, each of purge’s three deletes (completed, incomplete, dead), and every InboxDeadLetters call (list_dead/retry_dead/purge_dead) — never the caller’s claim/complete transaction, which is the caller’s own to bound. Exists chiefly for fail’s INSERT … ON CONFLICT DO UPDATE, which otherwise blocks unbounded behind a concurrent claimer’s still-open transaction on the same (scope, message_id) — a canceled statement classifies FailureKind::Transient, so leaving this at Duration::ZERO lets fail block for as long as the concurrent handler’s own transaction runs. Duration::ZERO (the default) issues nothing and inherits the server/role setting; a non-zero value costs a BEGIN/SET LOCAL/statement/COMMIT round trip on every call. STATEMENT_TIMEOUT_MS.

§max_attempts: u32

The bound crate::PostgresInboxStore’s InboxStore::fail applies to recorded failures before setting dead_at (ADR 0042 A.2.4). Lives here, in the provider, rather than in reliar-inbox, because the transition must be computed atomically with the increment — fail’s single INSERT … ON CONFLICT DO UPDATE decides attempts + 1 >= max_attempts in SQL.

0 is a configuration error, rejected by Self::validate and therefore by crate::PostgresInboxStore::connect0 reads as “no retries” and does the opposite. u32::MAX spells “unbounded” explicitly. Default 10. MAX_ATTEMPTS.

Implementations§

Source§

impl PostgresInboxSettings

Source

pub fn schema(self, schema: impl Into<String>) -> Self

Sets Self::schema.

use reliar_store_postgres::PostgresInboxSettings;
let settings = PostgresInboxSettings::default().schema("orders");
assert_eq!(settings.schema, "orders");
Source

pub const fn claim_sets_search_path(self, enabled: bool) -> Self

Sets Self::claim_sets_search_path.

use reliar_store_postgres::PostgresInboxSettings;
let settings = PostgresInboxSettings::default().claim_sets_search_path(true);
assert!(settings.claim_sets_search_path);
Source

pub const fn statement_timeout(self, timeout: Duration) -> Self

Sets Self::statement_timeout.

use reliar_store_postgres::PostgresInboxSettings;
use std::time::Duration;

let settings = PostgresInboxSettings::default()
    .statement_timeout(Duration::from_millis(500));
assert_eq!(settings.statement_timeout, Duration::from_millis(500));
Source

pub const fn max_attempts(self, max_attempts: u32) -> Self

Sets Self::max_attempts.

use reliar_store_postgres::PostgresInboxSettings;
let settings = PostgresInboxSettings::default().max_attempts(3);
assert_eq!(settings.max_attempts, 3);
Source

pub fn from_env(prefix: &str) -> Result<Self, SettingsError>

Opt-in, mirroring PostgresOutboxSettings::from_env. Starts from Self::default, overrides only the variables present under prefix.

§Errors

Returns SettingsError::Parse for a present-but-unparseable value.

Trait Implementations§

Source§

impl Clone for PostgresInboxSettings

Source§

fn clone(&self) -> PostgresInboxSettings

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PostgresInboxSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PostgresInboxSettings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PostgresInboxSettings

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for PostgresInboxSettings

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more