dynamicpg

package module
v0.0.0-...-b191d09 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: EUPL-1.2 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const ColumnNameInfix = "_role"
View Source
const MaxColumnNameLen = PGSQLNameDataLen - 1
View Source
const MaxColumnNameSlugLen = MaxColumnNameLen - len(ColumnNameInfix) - 3

MaxColumnNameSlugLen is the longest a slug can be and still fit the longest possible column name. Column name starts with a sluggified role name, followed by `_role` and a sequence number (max 999).

View Source
const MaxRoleCount = 999
View Source
const MaxTableNameLen = PGSQLNameDataLen - 1
View Source
const MaxTableNameSlugLen = MaxTableNameLen - TableNameHashLen - len(TableNameInfix)

MaxTableNameSlugLen is the longest a slug can be and still fit the longest possible table name. Table name starts with a sluggified claim type name, followed by `_claims_` and a hash of the original name.

View Source
const PGSQLNameDataLen = 64
View Source
const TableNameHashLen = 13
View Source
const TableNameInfix = "_claims_"

Variables

View Source
var PGSQLTableNameRE = regexp.MustCompile(`^[a-z_][a-z_0-9]*$`)

Functions

func New

func New(dbPool DBPool) *dynamicPGStore

New creates a new concurrency-safe data store for claims.

func PerformDBMigrations

func PerformDBMigrations(migrationsURL *url.URL, dsn string) error

PerformDBMigrations executes any necessary database migrations for the dynamic-pg data store. It does not use the data store's pool, because it should probably use different credentials/privileges. RH: ATTN: only file:// urls are supported.

Types

type DBPool

type DBPool interface {
	Begin(context.Context) (pgx.Tx, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	Reset()
}

DBPool defines all methods of [pgxpool.Pool] we need. This allows us to mock it in tests. RH: ATTN: pgx doesn't provide this interface: https://github.com/jackc/pgx/issues/644#issuecomment-562755159

Jump to

Keyboard shortcuts

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