Documentation
¶
Overview ¶
Package configs manages runtime-editable configuration stored in the `configs` table. Adding a new app-level knob is a two-step change:
- Declare a default in appDefaults() below + add its key constant.
- (Optional) Add a typed accessor on Service — e.g. AppURL(), SessionSecret() — so callers don't juggle strings.
Module-level configs live in each module's Config struct; the framework reflects those at boot via entity.StructToConfigs.
Values live in a cache guarded by RWMutex, populated at startup and refreshed on every Set() — so hot-reload is transparent to callers.
Index ¶
- Constants
- type Service
- func (s *Service) AdminPasswordChanged() bool
- func (s *Service) AppDescription() string
- func (s *Service) AppName() string
- func (s *Service) AppURL() string
- func (s *Service) Bootstrap(ctx context.Context, extras ...entity.Config) error
- func (s *Service) Get(key string) string
- func (s *Service) GetOwned(owner, key string) string
- func (s *Service) List() []entity.Config
- func (s *Service) ListOwned(owner string) []entity.Config
- func (s *Service) Missing(owner string) []string
- func (s *Service) Regenerate(ctx context.Context, key string) error
- func (s *Service) SessionSecret() string
- func (s *Service) Set(ctx context.Context, key, value string) error
- func (s *Service) SetOwned(ctx context.Context, owner, key, value string) error
Constants ¶
const ( KeyAppName = "app_name" DefaultAppName = "Wick Mini Tools" KeyAppDescription = "app_description" DefaultAppDescription = "A lightweight internal tooling platform — build, deploy, and run custom tools for your team in minutes." KeyAppURL = "app_url" KeySessionSecret = "session_secret" KeyAdminPasswordChanged = "admin_password_changed" )
Canonical key constants. Always reference a variable by these rather than the string literal — renaming then becomes a one-line change the compiler catches everywhere.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service exposes typed, cached access to runtime variables. The cache is loaded once at startup by Bootstrap() and refreshed on every Set() / Regenerate() call, so reads never touch the DB.
func NewService ¶
func (*Service) AdminPasswordChanged ¶
func (*Service) AppDescription ¶
func (*Service) Bootstrap ¶
Bootstrap reconciles the given extras plus the app-level defaults with the DB and seeds the in-memory cache. Pass module-declared Configs collected from every registered tool/job — wick assigns Owner before handing them off. Call once at startup, before anything else reads config.
func (*Service) Get ¶
Get returns the cached value for the app-level key (Owner==""). Callers should prefer typed accessors (AppURL, SessionSecret) so renames are compiler-enforced.
func (*Service) GetOwned ¶
GetOwned returns the cached value for (owner, key), or empty string if missing. Tool/job handlers use this via Ctx helpers; cross-owner reads are allowed but should be rare and intentional.
func (*Service) List ¶
List returns every app-level variable. Kept for backward compatibility with the admin settings page.
func (*Service) ListOwned ¶
ListOwned returns every config scoped to owner in declaration order (app-level follows appDefaults(); per-owner follows map iteration).
func (*Service) Missing ¶
Missing returns the keys of every Required row in owner that has no value stored. Tool handlers call this via Ctx.Missing() to render a "setup required" banner before doing any work.
func (*Service) Regenerate ¶
Regenerate replaces an app-level key's value by running its registered generator. Fails if the key is unknown, has no generator, or is not flagged CanRegenerate.