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 ¶
- Variables
- type ChangelogEntry
- type Entry
- type FileStore
- func (*FileStore) Changelog(_ context.Context, _ int) ([]ChangelogEntry, error)
- func (*FileStore) Delete(_ context.Context, _, _ string) error
- func (s *FileStore) Get(_ context.Context, key string) (*Entry, error)
- func (s *FileStore) List(_ context.Context) ([]Entry, error)
- func (*FileStore) Mode() string
- func (*FileStore) Set(_ context.Context, _, _, _ string) error
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("config entry not found")
ErrNotFound is returned when a requested config entry does not exist.
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 ¶
NewFileStore creates a FileStore from a map of key/value pairs.
func (*FileStore) Changelog ¶ added in v1.48.0
Changelog returns an empty slice because file-based config has no change history.
func (*FileStore) Delete ¶ added in v1.48.0
Delete returns ErrReadOnly because file-based config is immutable.
func (*FileStore) Get ¶ added in v1.48.0
Get returns the entry for the given key, or ErrNotFound if absent.
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.