namespace

package
v0.70.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 4 Imported by: 0

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

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.

func (*Namespace) AllCurrent

func (ns *Namespace) AllCurrent() map[string]*snapshot.Snapshot

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

func (ns *Namespace) Current(schemaID string) *snapshot.Snapshot

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

func (ns *Namespace) ID() string

ID returns the namespace identifier.

func (*Namespace) Promote

func (ns *Namespace) Promote() []string

Promote atomically moves all staged snapshots to current. Returns the schema IDs that were promoted.

func (*Namespace) ProposedView

func (ns *Namespace) ProposedView() map[string]*snapshot.Snapshot

ProposedView returns the proposed state: staged if available, otherwise current. This is the view used for compiling against the staging environment.

func (*Namespace) SchemaIDs

func (ns *Namespace) SchemaIDs() []string

SchemaIDs returns all schema IDs in this namespace.

func (*Namespace) SetCurrent

func (ns *Namespace) SetCurrent(schemaID string, snap *snapshot.Snapshot) *snapshot.Snapshot

SetCurrent atomically swaps the current snapshot for a schema. Returns the previous snapshot (may be nil).

func (*Namespace) SetStaged

func (ns *Namespace) SetStaged(schemaID string, snap *snapshot.Snapshot)

SetStaged sets the staged snapshot for a schema.

func (*Namespace) Staged

func (ns *Namespace) Staged(schemaID string) *snapshot.Snapshot

Staged returns the staged snapshot for a schema, or nil if nothing is staged.

func (*Namespace) String

func (ns *Namespace) String() string

String returns a human-readable representation.

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 NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new namespace registry.

func (*Registry) Get

func (r *Registry) Get(id string) *Namespace

Get returns the namespace with the given ID, or nil if it doesn't exist.

func (*Registry) GetOrCreate

func (r *Registry) GetOrCreate(id string) *Namespace

GetOrCreate returns an existing namespace or creates a new one.

func (*Registry) Range

func (r *Registry) Range(fn func(ns *Namespace) bool)

Range iterates over all namespaces.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL