config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config is the app's live settings: declared by the core and by modules, kept in the app's database, and read at the moment of use. A change is stored, then announced on the bus and to watchers; nothing has to restart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// Scope is the module id, or "surface" for the core's own.
	Scope string `json:"scope"`
	module.Setting
	// FullKey is "<scope>.<key>".
	FullKey string `json:"full_key"`
	Value   any    `json:"value"`
	// Set is true when the user has set a value; false means Value is the default.
	Set bool `json:"set"`
}

Entry is one setting with its present value, as the settings window lists it.

type Publisher

type Publisher interface {
	Publish(topic string, data any)
}

Publisher announces a change. The events bus satisfies it.

type Store

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

Store holds the declarations and the values.

func Open

func Open(ctx context.Context, db *sql.DB, pub Publisher) (*Store, error)

Open loads the stored values. The table is created by the core's migrations.

func (*Store) Declare

func (s *Store) Declare(scope string, settings []module.Setting) error

Declare registers a scope's settings. A default that does not fit its type is an error.

func (*Store) Entries

func (s *Store) Entries() []Entry

Entries lists every declared setting with its value, by scope then key.

func (*Store) Get

func (s *Store) Get(fullKey string) (any, bool)

Get returns the present value of a full key: the user's, or the default.

func (*Store) Reset

func (s *Store) Reset(ctx context.Context, fullKey string) error

Reset removes the user's value, so the default applies again.

func (*Store) Scoped

func (s *Store) Scoped(scope string) module.Config

Scoped is one scope's view of the store. It implements module.Config.

func (*Store) Set

func (s *Store) Set(ctx context.Context, fullKey string, value any) error

Set validates and stores a value, then tells watchers and the bus ("config.changed").

func (*Store) Watch

func (s *Store) Watch(fullKey string, fn func(any)) (stop func())

Watch calls fn after fullKey changes.

Jump to

Keyboard shortcuts

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