Documentation
¶
Overview ¶
Package postgres provides the Postgres concrete tenancy.Provider. It installs Row-Level Security policies at migration time and binds per-request tenancy state via pgxpool BeforeAcquire / AfterRelease hooks. Combined, application code never references tenant_id or partition_id directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the Postgres concrete tenancy.Provider. It installs RLS policies during Migrate and binds per-request tenancy state via pgxpool acquire/release hooks (no transactions required).
func (*Provider) Capabilities ¶
func (*Provider) Capabilities() tenancy.Capabilities
Capabilities implements tenancy.Provider.
func (*Provider) Install ¶
Install implements tenancy.Provider. Idempotent:
- CREATE OR REPLACE for the SQL function
- DROP POLICY IF EXISTS / CREATE POLICY pair per table
- ALTER TABLE … ENABLE / FORCE ROW LEVEL SECURITY (Postgres no-ops if already enabled).
func (*Provider) WireAdapter ¶
func (p *Provider) WireAdapter(adapter dialect.DialectAdapter) error
WireAdapter implements tenancy.Provider. Stashes the adapter (for identifier quoting in Install), then registers a BeforeAcquire hook that pushes Claims-derived session vars onto the connection and an AfterRelease hook that resets them so connections are returned to the pool clean.