settings

package
v0.0.0-...-1a3a2fa Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const StoreCtxKey storeCtxKey = "store"

Variables

View Source
var ConfigDefaults = Defaults{
	prefsName("stillbox"): MustMarshal(Defaults{
		"calls.view.showSourceAlias": false,
		"calls.view.showTranscripts": false,
	}),
}
View Source
var (
	ErrNoSetting = errors.New("no such setting")
)

Functions

func CtxWithStore

func CtxWithStore(ctx context.Context, s Store) context.Context

func MustMarshal

func MustMarshal(s any) json.RawMessage

func New

func New(db database.Store, defaults Defaults) *postgresStore

Types

type Defaults

type Defaults map[string]Setting

type Setting

type Setting any

type Store

type Store interface {
	// Get gets a setting and unmarshals it into dst.
	Get(ctx context.Context, name string) (Setting, error)

	// GetPrefs gets system prefs for an app name.
	GetPrefs(ctx context.Context, appName string) (json.RawMessage, error)

	// SetPrefs sets system prefs for an app name.
	SetPrefs(ctx context.Context, appName string, val Setting) error

	// Set sets a setting.
	Set(ctx context.Context, name string, val Setting) error

	// GetInto gets a setting and unmarshals it directly into into.
	// It does *not* use the cache, and does *not* support defaults.
	GetInto(ctx context.Context, name string, into any) error

	// Delete removes a setting.
	Delete(ctx context.Context, name string) error
}

func FromCtx

func FromCtx(ctx context.Context) Store

Jump to

Keyboard shortcuts

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