Documentation
¶
Overview ¶
Package namespace provides the isolation boundary for schemas. Each namespace maintains independent current and staged snapshots, with lock-free reads via atomic pointers and serialized writes.
Index ¶
- type Namespace
- func (ns *Namespace) AllCurrent() map[string]*snapshot.Snapshot
- func (ns *Namespace) Chain() []*Namespace
- func (ns *Namespace) Current(schemaID string) *snapshot.Snapshot
- func (ns *Namespace) DiscardStaging()
- func (ns *Namespace) ID() string
- func (ns *Namespace) Parent() *Namespace
- func (ns *Namespace) Promote() []string
- func (ns *Namespace) ProposedView() map[string]*snapshot.Snapshot
- func (ns *Namespace) SchemaIDs() []string
- func (ns *Namespace) SetCurrent(schemaID string, snap *snapshot.Snapshot) *snapshot.Snapshot
- func (ns *Namespace) SetParent(parent *Namespace)
- func (ns *Namespace) SetStaged(schemaID string, snap *snapshot.Snapshot)
- func (ns *Namespace) Staged(schemaID string) *snapshot.Snapshot
- func (ns *Namespace) String() string
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace is an isolation boundary containing schemas.
Schemas within a namespace can import each other's files; cross-namespace imports are not allowed. However, type *resolution* may walk the namespace hierarchy via the parent pointer (see SetParent / Parent / Chain). Resolution chaining is distinct from imports: the chain is consulted on lookup miss, but no source file ever names another namespace. See docs/design/namespace-hierarchy.md for the full design.
Phase 1 ships the parent pointer and chain accessor; phase 2 wires the compiler and resolver to actually walk the chain.
func (*Namespace) AllCurrent ¶
AllCurrent returns a map of schema ID → current snapshot for all schemas that have a current version. Used for building the namespace resolver during compilation.
func (*Namespace) Chain ¶ added in v0.71.0
Chain returns the resolution chain starting with this namespace and walking parent pointers to the root. The slice is ordered nearest-first (this namespace at index 0). Walks are bounded by chainMaxDepth as a defensive guard against cycles; the implicit __builtins__ and Google WKT tiers are not included (they are appended by the resolver).
Safe for concurrent use; the snapshot reflects parent pointers as seen at the moment of each Load.
func (*Namespace) Current ¶
Current returns the current snapshot for a schema, or nil if no version has been promoted.
func (*Namespace) DiscardStaging ¶
func (ns *Namespace) DiscardStaging()
DiscardStaging clears all staged snapshots.
func (*Namespace) Parent ¶ added in v0.71.0
Parent returns the namespace's parent in the resolution chain, or nil when this namespace is a root (resolution then falls back to the implicit __builtins__ namespace and then Google WKT — see decision D4). Safe for concurrent use.
func (*Namespace) Promote ¶
Promote atomically moves all staged snapshots to current. Returns the schema IDs that were promoted.
func (*Namespace) ProposedView ¶
ProposedView returns the proposed state: staged if available, otherwise current. This is the view used for compiling against the staging environment.
func (*Namespace) SetCurrent ¶
SetCurrent atomically swaps the current snapshot for a schema. Returns the previous snapshot (may be nil).
func (*Namespace) SetParent ¶ added in v0.71.0
SetParent atomically sets the resolution-chain parent. Pass nil to clear it. Safe for concurrent use, but callers are responsible for preventing cycles — the in-memory model trusts whatever the store layer admitted (see SetNamespaceParent in the store package, which enforces acyclicity via recursive CTE).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages all namespaces. It is the top-level entry point for looking up and creating namespaces.
func (*Registry) GetOrCreate ¶
GetOrCreate returns an existing namespace or creates a new one.