livekeys

package
v1.3.7-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package livekeys serves the design-key list (features.design_preview) from a file the process re-reads while it runs, so turning a key on or off needs no pod restart. In the cluster the file is a ConfigMap mounted as a directory (deploy/helm/rivolt, liveKeys.designPreview), changed only by a reviewed commit that Argo CD syncs; kubelet refreshes the mount and the poll here picks the change up.

File format: one line, design_preview=a,b,c. An empty value is valid and means every key off. A zero-byte file, a file without the line, or a key outside [a-z0-9_] is rejected as a whole and the last good list stays; a pod never falls back to "all off" because of a bad file.

A pod that starts with no good list to keep follows two rules. An ABSENT file (the ConfigMap is missing) uses RIVOLT_DESIGN_PREVIEW, the start-up fallback. A PRESENT but invalid file never does: running pods serve the last good file list and the env may lag it, so the pod reports source "invalid" and Ready() false (the pod stays out of the Service, a roll stalls) until the file is fixed; the next poll recovers it.

Index

Constants

View Source
const (
	SourceFile = "file" // the list came from the mounted file
	SourceEnv  = "env"  // booted without a good file; the list is RIVOLT_DESIGN_PREVIEW (the migration fallback), until the file is good
	SourceNone = "none" // no file configured (or an explicit empty env) and no env list: empty list
	// SourceInvalid: the pod has no good list and must not serve an empty one as if intended: the file is present but invalid, or it is
	// absent and there is no env fallback. Ready() is false until a good file arrives.
	SourceInvalid = "invalid"
)

Sources reported on rivolt_live_keys_info.

View Source
const PollInterval = 10 * time.Second

PollInterval is how often the file is re-read. The path is read afresh each time, so kubelet's ..data symlink swap is followed.

Variables

This section is empty.

Functions

func ParseFile

func ParseFile(b []byte) ([]string, error)

ParseFile reads the file body. See the package comment for what is valid.

func SplitList

func SplitList(s string) []string

SplitList splits a comma-separated key list: spaces are trimmed, empty entries and repeats dropped, order kept. Empty input gives an empty (non-nil) list.

func ValidKeys

func ValidKeys(keys []string) error

ValidKeys reports the first key outside [a-z0-9_] (or empty).

Types

type Store

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

Store holds the current list. Keys is safe for any number of concurrent readers.

func New

func New(path, env string, log *slog.Logger) (*Store, error)

New builds the store and loads once, before the caller serves anything. path may be empty (no file configured): the list is then env, source "env" or "none". env is the raw RIVOLT_DESIGN_PREVIEW value; a bad env list is an error the caller treats as fatal, so it never drops silently.

func (*Store) Collectors

func (s *Store) Collectors() []prometheus.Collector

Collectors are the store's metrics, to register once.

func (*Store) Has

func (s *Store) Has(key string) bool

Has reports whether key is on.

func (*Store) Keys

func (s *Store) Keys() []string

Keys returns a copy of the current list (never nil).

func (*Store) Ready added in v1.3.2

func (s *Store) Ready() bool

Ready is false while the pod has no good list (source "invalid"); the readiness probe follows it on every reload.

func (*Store) Reload

func (s *Store) Reload()

Reload reads the file once (the poll). See reloadFile.

func (*Store) Run

func (s *Store) Run(stop <-chan struct{}, every time.Duration)

Run polls until stop is closed.

func (*Store) SHA

func (s *Store) SHA() string

SHA is the short hash of the served list; Source is where it came from.

func (*Store) Source

func (s *Store) Source() string

Jump to

Keyboard shortcuts

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