Documentation
¶
Overview ¶
Package nodegroup is the node-group definition store: named collections of Data-Plane nodes matched by label selectors (geo-aware grouping, tiered routing, policy scoping), with atomic JSON persistence. It is extracted from package main per ADR-0002; the admin API handlers, the EnrolledNode-typed membership filter, and the globalNodeGroups singleton stay in main (nodegroup.go shim).
Index ¶
- func LabelsMatch(selector, labels map[string]string) bool
- type Group
- type Store
- func (s *Store) Add(g Group) (Group, error)
- func (s *Store) AddErr(g Group) (added Group, persistErr, err error)
- func (s *Store) Delete(name string) bool
- func (s *Store) DeleteErr(name string) (found bool, persistErr error)
- func (s *Store) Get(name string) (Group, bool)
- func (s *Store) List() []Group
- func (s *Store) LoadErr() error
- func (s *Store) MatchingGroups(labels map[string]string) []string
- func (s *Store) Path() string
- func (s *Store) ReplaceAll(groups []Group)
- func (s *Store) Save()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LabelsMatch ¶
LabelsMatch returns true when every k/v in selector exists in labels.
Types ¶
type Group ¶
type Group struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
LabelSelector map[string]string `json:"label_selector"` // all must match
Priority int `json:"priority,omitempty"`
CreatedAt string `json:"created_at"`
}
Group defines a named collection of Data Plane nodes matched by label selectors. Used for geo-aware grouping, tiered routing, and policy scoping.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists node group definitions to a JSON file.
func (*Store) Add ¶
Add validates and appends a new node group. A failed write is logged only; AddErr reports it.
func (*Store) AddErr ¶ added in v1.0.584
AddErr is Add that also reports a failed write. err is a validation refusal: nothing changed. persistErr means the group IS applied in memory but did not reach disk, so a restart drops it.
func (*Store) Delete ¶
Delete removes a node group by name. Returns true if found and removed. A failed write is logged only; DeleteErr reports it.
func (*Store) DeleteErr ¶ added in v1.0.584
DeleteErr is Delete that also reports a failed write: persistErr means the group IS removed in memory but still on disk, so a restart restores it.
func (*Store) LoadErr ¶ added in v1.0.584
LoadErr reports why the store file existed but could not be read or parsed when the store was created, or nil.
func (*Store) MatchingGroups ¶
MatchingGroups returns the names of groups whose label selectors are satisfied by the given labels map. A group matches when every key-value pair in its LabelSelector exists in labels.
func (*Store) ReplaceAll ¶
ReplaceAll atomically replaces all groups (used by config snapshot sync).