|
ORE Studio 0.0.4
|
A connection pool wrapper that sets tenant and party context on acquire. More...
#include <tenant_aware_pool.hpp>

Public Member Functions | |
| tenant_aware_pool (sqlgen::ConnectionPool< Connection > pool, utility::uuid::tenant_id tenant_id, std::string actor="", std::string service_account="") | |
| Constructs a tenant-aware pool wrapper (tenant-only). | |
| tenant_aware_pool (sqlgen::ConnectionPool< Connection > pool, utility::uuid::tenant_id tenant_id, boost::uuids::uuid party_id, std::vector< boost::uuids::uuid > visible_party_ids, std::string actor="", std::string service_account="") | |
| Constructs a tenant-and-party-aware pool wrapper. | |
| sqlgen::Result< sqlgen::Ref< sqlgen::Session< Connection > > > | acquire () noexcept |
| Acquires a session and sets the tenant (and party) context. | |
| const utility::uuid::tenant_id & | tenant_id () const |
| Gets the current tenant ID. | |
| std::optional< boost::uuids::uuid > | party_id () const |
| Gets the current party ID, if set. | |
| const std::vector< boost::uuids::uuid > & | visible_party_ids () const |
| Gets the visible party IDs. | |
| const std::string & | actor () const |
| Gets the current actor (username), if set. | |
| const std::string & | service_account () const |
| Gets the current service account, if set. | |
| const sqlgen::ConnectionPool< Connection > & | underlying_pool () const |
| Gets the underlying connection pool. | |
| size_t | available () const |
| Gets the number of available connections. | |
| size_t | size () const |
| Gets the total number of connections in the pool. | |
A connection pool wrapper that sets tenant and party context on acquire.
PostgreSQL session variables are per-connection. When using a connection pool, different operations may get different connections, causing RLS policies that check the session variable to fail.
This wrapper ensures that whenever a connection is acquired from the pool, the tenant context (and optionally party context) is set via SET_CONFIG before returning the session. This allows RLS policies to work correctly with connection pooling.