pathctx

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pathctx carries the tenant's Postgres schema on context.Context for schema-per-tenant "consolidation mode": the adapter stamps SET LOCAL search_path from it per transaction, exactly as core/tenant's id is stamped into SET LOCAL app.tenant_id. The value is OPTIONAL — when absent (single/shards/database modes) the adapter stamps nothing new and behaves identically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustWithSearchPath

func MustWithSearchPath(ctx context.Context, schema string) context.Context

MustWithSearchPath is WithSearchPath for wiring code; panics on invalid.

func SchemaForTenant

func SchemaForTenant(tenantID string) (string, error)

SchemaForTenant maps a tenant id to its consolidation-mode schema name: "tenant_" + the id with '-' folded to '_' (tenant ids allow '-', which is illegal in a bare Postgres identifier). It fails CLOSED for ids that cannot map to a legal schema — uppercase (Postgres folds unquoted identifiers to lowercase, so "Acme" and "acme" would collide) or too long — rather than silently folding to a colliding name. The mapping is deterministic, so routing derives the schema without a catalog lookup; provisioning persists the same value in Entry.Schema.

func SchemaOrEmpty

func SchemaOrEmpty(ctx context.Context) string

SchemaOrEmpty returns the stamped schema, or "" when none is set.

func ValidSchema

func ValidSchema(s string) bool

ValidSchema reports whether s is a well-formed tenant schema name.

func WithSearchPath

func WithSearchPath(ctx context.Context, schema string) (context.Context, error)

WithSearchPath stamps the tenant schema on ctx, or errors if malformed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL