namespaces

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package namespaces is the RAFT FSM adapter for namespace control-plane state. It translates *cmd.ApplyRequest / *cmd.QueryRequest payloads into typed calls on the shared controller, which owns the state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynusersNamespaceLister

type DynusersNamespaceLister interface {
	UsersInNamespace(namespace string) []string
}

DynusersNamespaceLister returns the dynamic DB users that belong to a namespace.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is the RAFT FSM adapter. It does not own state.

func NewManager

func NewManager(
	controller *usecasesNamespaces.Controller,
	schema SchemaNamespaceLister,
	dynusers DynusersNamespaceLister,
	logger logrus.FieldLogger,
) *Manager

NewManager wraps the controller and the listers RemoveEntity consults to verify the namespace is empty. Panics on a nil controller or nil schema lister. The dynusers lister is optional: deployments without dynamic users pass nil and the user check is skipped.

func (*Manager) Add

func (m *Manager) Add(c *cmd.ApplyRequest) error

Add applies an AddNamespace RAFT command. It rejects malformed payloads and invalid names with usecasesNamespaces.ErrBadRequest, and duplicates with usecasesNamespaces.ErrAlreadyExists.

func (*Manager) ChangeState

func (m *Manager) ChangeState(c *cmd.ApplyRequest) error

ChangeState applies a ChangeNamespaceState RAFT command, transitioning the namespace into the target state. Returns usecasesNamespaces.ErrBadRequest for malformed payloads or unknown target states, usecasesNamespaces.ErrNotFound when the namespace does not exist, and usecasesNamespaces.ErrInvalidStateTransition when the requested transition is forbidden.

func (*Manager) Count

func (m *Manager) Count() int

Count returns the number of known namespaces. Used by the startup invariant check.

func (*Manager) Exists

func (m *Manager) Exists(name string) bool

Exists proxies to the controller. Lets the apply switch satisfy usecasesNamespaces.Exister from a single namespaceManager reference.

func (*Manager) Get

func (m *Manager) Get(req *cmd.QueryRequest) ([]byte, error)

Get handles a QueryGetNamespaces query. An empty Names slice returns all known namespaces; otherwise only the named ones that exist are returned (missing names are silently omitted).

func (*Manager) GetNamespace

func (m *Manager) GetNamespace(name string) (ns cmd.Namespace, ok bool)

GetNamespace returns the namespace by name. ok is false when the namespace does not exist.

func (*Manager) IsActive

func (m *Manager) IsActive(name string) bool

IsActive proxies to the controller.

func (*Manager) List

func (m *Manager) List() []cmd.Namespace

List returns a snapshot copy of all namespaces.

func (*Manager) RemoveEntity

func (m *Manager) RemoveEntity(c *cmd.ApplyRequest) error

RemoveEntity applies a RemoveNamespaceEntity RAFT command. Returns usecasesNamespaces.ErrBadRequest for malformed payloads, usecasesNamespaces.ErrNotFound when the namespace does not exist, usecasesNamespaces.ErrInvalidState when called on an active namespace, and usecasesNamespaces.ErrNamespaceNotEmpty when classes, aliases, or users still remain in the namespace.

func (*Manager) Restore

func (m *Manager) Restore(snapshot []byte) error

Restore replaces the current state with the snapshot contents.

func (*Manager) Snapshot

func (m *Manager) Snapshot() ([]byte, error)

Snapshot serializes the entire namespace map.

func (*Manager) Update

func (m *Manager) Update(c *cmd.ApplyRequest) error

Update applies an UpdateNamespace RAFT command. It rewrites the stored HomeNode for an existing namespace. Returns usecasesNamespaces.ErrBadRequest for malformed payloads or an empty HomeNode, and usecasesNamespaces.ErrNotFound when the namespace does not exist.

type SchemaNamespaceLister

type SchemaNamespaceLister interface {
	ClassesInNamespace(namespace string) ([]string, error)
	AliasesInNamespace(namespace string) []string
}

SchemaNamespaceLister returns the classes and aliases that belong to a namespace.

Jump to

Keyboard shortcuts

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