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) Get(req *cmd.QueryRequest) ([]byte, error)
- func (m *Manager) GetNamespace(name string) (ns cmd.Namespace, ok 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 RBACNamespaceLister
- 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, rbac RBACNamespaceLister, 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 and rbac listers are optional: deployments without dynamic users or RBAC pass nil and the respective check is skipped.
func (*Manager) Add ¶
func (m *Manager) Add(c *cmd.ApplyRequest) error
Add applies an AddNamespace RAFT command, recording the command's RAFT log index on the new namespace. 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 and recording the command's RAFT log index against it. A nonzero req.ExpectedStateChangeIndex is enforced as a precondition: the flip is refused with usecasesNamespaces.ErrStateChangedConcurrently unless the namespace is still at that index. 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) 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, users, or RBAC rows 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.
type RBACNamespaceLister ¶ added in v1.38.3
RBACNamespaceLister counts the local roles and role assignments that still belong to a namespace.