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 ¶
- type DynusersNamespaceLister
- type Manager
- func (m *Manager) Add(c *cmd.ApplyRequest) error
- func (m *Manager) ChangeState(c *cmd.ApplyRequest) error
- func (m *Manager) Count() int
- func (m *Manager) Exists(name string) bool
- func (m *Manager) Get(req *cmd.QueryRequest) ([]byte, error)
- func (m *Manager) GetNamespace(name string) (ns cmd.Namespace, ok bool)
- func (m *Manager) IsActive(name string) bool
- func (m *Manager) List() []cmd.Namespace
- func (m *Manager) RemoveEntity(c *cmd.ApplyRequest) error
- func (m *Manager) Restore(snapshot []byte) error
- func (m *Manager) Snapshot() ([]byte, error)
- func (m *Manager) Update(c *cmd.ApplyRequest) error
- type SchemaNamespaceLister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynusersNamespaceLister ¶
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 ¶
Count returns the number of known namespaces. Used by the startup invariant check.
func (*Manager) Exists ¶
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 ¶
GetNamespace returns the namespace by name. ok is false when the namespace does not exist.
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) 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.