internal/docsite/schema.go
internal/docsite · 464 lines · 19 declarations · source
Declarations
const testControlPassword, testDataPassword, bootstrapLock and 2 more
const (
// The instance roles are cluster-wide, so bootstrapping sets their passwords on the whole
// substrate. These are the passwords the test suite sets, and bootstrap runs under the suite's
// own lock, so a build and a test run leave the substrate in the same state and cannot race.
testControlPassword = "taisce-test-control"
testDataPassword = "taisce-test-data"
// bootstrapLock is the key EstablishPlanes and the suites serialise role changes on.
bootstrapLock = "taisce:establish-planes"
// exampleProject is provisioned so the reference shows a project's partitions.
exampleProject = "example"
memoryNamespace = "memory"
)
func withScratchDatabase
func withScratchDatabase(ctx context.Context, root, dsn string, fn func(*pgxpool.Pool) error) (err error)
withScratchDatabase creates an empty database on the substrate, gives it the extensions the substrate image gives its own database at first start, bootstraps it, hands a pool on it to fn, and drops it afterwards whatever fn returned.
The extensions come from deploy/postgres/initdb, the files the image runs, rather than from a list here: one bootstrap for a deployment, the suite and the site, so none of them can describe a database the others would not build.
func bootstrap
func bootstrap(ctx context.Context, pool *pgxpool.Pool) error
bootstrap does what a deployment's bootstrap does, through the same functions.
func renderSchema
func renderSchema(ctx context.Context, opts Options) (rendered, int, error)
func describe
func describe(ctx context.Context, pool *pgxpool.Pool) (rendered, int, error)
describe renders the reference from a bootstrapped database.
type querier
type querier struct {
ctx context.Context
pool *pgxpool.Pool
err error
}
querier carries the first error so the rendering reads as a description rather than a ladder of error checks; nothing is written once err is set, and describe reports it.
method querier.one
func (q *querier) one(sql string, dest ...any)
method querier.rows
func (q *querier) rows(sql string, args ...any) [][]string
method querier.strings
func (q *querier) strings(sql string, args ...any) []string
method querier.namespace
func (q *querier) namespace(ns, label, about string) (string, int)
namespace renders one namespace and returns how many tables it holds.
method querier.table
func (q *querier) table(b *strings.Builder, r []string)
method querier.list
func (q *querier) list(b *strings.Builder, label, sql string, args ...any)
list renders name/definition pairs under a bold label, and nothing when there are none.
method querier.views
func (q *querier) views(b *strings.Builder, ns string)
method querier.functions
func (q *querier) functions(b *strings.Builder, ns string)
method querier.types
func (q *querier) types(b *strings.Builder, ns string)
method querier.roles
func (q *querier) roles() string
roles renders the identities and a grant matrix, which is the privilege boundary stated by the database rather than by anybody's description of it.
func yes
func yes(v string) string
func orNone
func orNone(v string) string
func code
func code(s string) string
code renders a definition as a code span, or nothing for an empty one.