Documentation ¶
Index ¶
Constants ¶
const ColumnNameInfix = "_role"
const MaxColumnNameLen = PGSQLNameDataLen - 1
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).
const MaxRoleCount = 999
const MaxTableNameLen = PGSQLNameDataLen - 1
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.
const PGSQLNameDataLen = 64
const TableNameHashLen = 13
const TableNameInfix = "_claims_"
Variables ¶
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 ¶
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