Skip to main content

Module scope

Module scope 

Source
Expand description

Per-request connection scoping for pooled multi-tenancy.

Extensions register a ConnectionScopeProvider that translates a RequestScope into transaction-local Postgres settings (custom GUCs such as app.current_org) applied via set_config($1, $2, true) on a scoped transaction — the parameterizable equivalent of SET LOCAL, which cannot bind parameters. Row-level-security policies then read the setting with current_setting('app.current_org', true).

The seam is strictly opt-in: only begin_scoped and the with_scoped_transaction* wrappers in crate::services consult the registry, and with no registered provider they degenerate to a plain pool.begin(). Existing transaction and pool APIs are untouched.

Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.

Structs§

ScopeProviderRegistration
One inventory submission per crate::register_scope_provider! call.
ScopeSetting
One transaction-local setting to apply on a scoped transaction.

Enums§

ScopeError

Traits§

ConnectionScopeProvider
Translates a RequestScope into transaction-local settings.

Functions§

discover_scope_providers
Construct every registered provider, in collection order.
scope_providers
The process-wide provider list, constructed once on first use. An empty slice (no extension registered) keeps every scoped-transaction call a plain pool.begin().

Type Aliases§

SharedScopeProvider