Skip to main content

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"
)

source

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.

source

func bootstrap​

func bootstrap(ctx context.Context, pool *pgxpool.Pool) error

bootstrap does what a deployment's bootstrap does, through the same functions.

source

func renderSchema​

func renderSchema(ctx context.Context, opts Options) (rendered, int, error)

source

func describe​

func describe(ctx context.Context, pool *pgxpool.Pool) (rendered, int, error)

describe renders the reference from a bootstrapped database.

source

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.

source

method querier.one​

func (q *querier) one(sql string, dest ...any)

source

method querier.rows​

func (q *querier) rows(sql string, args ...any) [][]string

source

method querier.strings​

func (q *querier) strings(sql string, args ...any) []string

source

method querier.namespace​

func (q *querier) namespace(ns, label, about string) (string, int)

namespace renders one namespace and returns how many tables it holds.

source

method querier.table​

func (q *querier) table(b *strings.Builder, r []string)

source

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.

source

method querier.views​

func (q *querier) views(b *strings.Builder, ns string)

source

method querier.functions​

func (q *querier) functions(b *strings.Builder, ns string)

source

method querier.types​

func (q *querier) types(b *strings.Builder, ns string)

source

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.

source

func yes​

func yes(v string) string

source

func orNone​

func orNone(v string) string

source

func code​

func code(s string) string

code renders a definition as a code span, or nothing for an empty one.

source