Documentation
¶
Overview ¶
Package settings is a platform module: business settings of the project, stored in the database and editable without a deploy.
The schema is generated from settings.yaml and comes from project code; the module adds storage, caching, refresh and the store in the container.
Index ¶
Constants ¶
const DefaultTable = "platform_settings"
DefaultTable is where overrides are stored.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Table string // table holding the overrides
// RefreshInterval is how often values are re-read, so a change made on one instance
// reaches the others. Zero disables the refresh loop.
RefreshInterval time.Duration
}
Config holds module settings. Load fills it from the environment; the platform generator writes the Load call into the project's config.gen.go.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements platform.Module.
func (*Module) Health ¶
Health fails when the settings cannot be re-read: the application still works on the cached values, yet a change would not reach it, and that must be visible.
func (*Module) Init ¶
Init creates the table, loads the values and puts the store into the container, where project code picks it up through the generated accessors.
type Report ¶ added in v0.9.0
type Report = settingsx.ImportReport
Report says what an import did with every key; see settingsx.ImportReport.
func Import ¶ added in v0.9.0
func Import(ctx context.Context, app *platform.App, values map[string]string, by string) (Report, error)
Import moves settings kept elsewhere into the settings of the module, storing only the values that differ from the defaults of the schema. It is safe to repeat; see settingsx.Store.Import for the rules. The settings module must be initialised, so a project calls it from wireDomain or from a command built on the platform.
func ImportQuery ¶ added in v0.9.0
func ImportQuery(ctx context.Context, app *platform.App, db Querier, query, by string) (Report, error)
ImportQuery imports the settings a query returns. The query yields two text columns, the key and the value, for example
SELECT key, value FROM app_configs
A NULL value means "use the default", the way taply's app_configs stores it, so it is imported as the default of the schema: nothing is stored, and the key is reported among the defaults, the kept or the unknown keys.