Documentation
¶
Overview ¶
Package resource is the kernel resource registry and the thin tenant mirror that lets kernel services (authz record-scope, comments, documents, workflow, relationships) address any module row uniformly. A module owns its business table; on write it upserts a matching row into the kernel `resources` table (same id) via a Registrar, declaring the resource type. See blueprint 01 §3, 03 §2, 04 §2.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidTypeKey ¶
ValidTypeKey reports whether key is a legal resource type key.
Types ¶
type PgRegistrar ¶
type PgRegistrar struct{}
PgRegistrar is the Postgres-backed resource Registrar factory. It carries no state of its own: a Registrar must run inside the caller's tenant transaction so the mirror row and the business write commit atomically, and the tx's TenantDB is only available per unit of work. Bind supplies that db and yields a Registrar bound to it.
func NewRegistrar ¶
func NewRegistrar() *PgRegistrar
NewRegistrar returns the Postgres resource registrar factory.
type Ref ¶
type Ref struct {
Type string `json:"type"` // registered resource_types.key, e.g. "requests.request"
ID uuid.UUID `json:"id"`
}
Ref is a kernel-wide pointer to any domain object: its registered type key plus id. It is the currency of authz targets, relationships, comments, and attachments.
type Registrar ¶
type Registrar interface {
// Upsert writes (or updates) the resources row: same id as the module row,
// its resource type, optional org, a human label, and status.
Upsert(ctx context.Context, ref Ref, orgID *uuid.UUID, label, status string) error
}
Registrar upserts the kernel resources mirror row for a module aggregate, inside the caller's tenant transaction so the mirror and the business write commit atomically. The concrete implementation lives beside the DB layer and receives the TenantDB; this port keeps module code off the raw pool.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry accumulates resource type declarations during module registration and is synced to the resource_types table at boot. Duplicate keys and keys whose module prefix does not match the registering module are errors.