configstore

package
v1.50.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package configstore provides granular key/value storage for platform configuration entries. DB entries override file config for whitelisted keys, with per-key hot-reload support.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("config entry not found")

ErrNotFound is returned when a requested config entry does not exist.

View Source
var ErrReadOnly = errors.New("config store is read-only")

ErrReadOnly is returned when a write operation is attempted on a read-only store.

Functions

This section is empty.

Types

type ChangelogEntry added in v1.48.0

type ChangelogEntry struct {
	ID        int       `json:"id"`
	Key       string    `json:"key"`
	Action    string    `json:"action"`
	Value     *string   `json:"value,omitempty"`
	ChangedBy string    `json:"changed_by"`
	ChangedAt time.Time `json:"changed_at"`
}

ChangelogEntry records a single config change for audit purposes.

type Entry added in v1.48.0

type Entry struct {
	Key       string    `json:"key"`
	Value     string    `json:"value"`
	UpdatedBy string    `json:"updated_by"`
	UpdatedAt time.Time `json:"updated_at"`
}

Entry represents a single config key/value pair.

type FileStore

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

FileStore provides read-only config entries from a static map. Write operations return ErrReadOnly.

func NewFileStore

func NewFileStore(entries map[string]string) *FileStore

NewFileStore creates a FileStore from a map of key/value pairs.

func (*FileStore) Changelog added in v1.48.0

func (*FileStore) Changelog(_ context.Context, _ int) ([]ChangelogEntry, error)

Changelog returns an empty slice because file-based config has no change history.

func (*FileStore) Delete added in v1.48.0

func (*FileStore) Delete(_ context.Context, _, _ string) error

Delete returns ErrReadOnly because file-based config is immutable.

func (*FileStore) Get added in v1.48.0

func (s *FileStore) Get(_ context.Context, key string) (*Entry, error)

Get returns the entry for the given key, or ErrNotFound if absent.

func (*FileStore) List added in v1.48.0

func (s *FileStore) List(_ context.Context) ([]Entry, error)

List returns all entries from the static map, sorted by key.

func (*FileStore) Mode

func (*FileStore) Mode() string

Mode returns "file".

func (*FileStore) Set added in v1.48.0

func (*FileStore) Set(_ context.Context, _, _, _ string) error

Set returns ErrReadOnly because file-based config is immutable.

type Store

type Store interface {
	// Get returns a single config entry by key, or ErrNotFound if absent.
	Get(ctx context.Context, key string) (*Entry, error)
	// Set creates or updates a config entry and logs the change.
	Set(ctx context.Context, key, value, author string) error
	// Delete removes a config entry and logs the change. Returns ErrNotFound if absent.
	Delete(ctx context.Context, key, author string) error
	// List returns all config entries, ordered by key.
	List(ctx context.Context) ([]Entry, error)
	// Changelog returns recent config changes, newest first.
	Changelog(ctx context.Context, limit int) ([]ChangelogEntry, error)
	// Mode returns the store mode: "file" or "database".
	Mode() string
}

Store provides granular key/value config storage with audit logging.

Directories

Path Synopsis
Package postgres provides a PostgreSQL-backed granular config entry store.
Package postgres provides a PostgreSQL-backed granular config entry store.

Jump to

Keyboard shortcuts

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