Documentation
¶
Overview ¶
Package config implements service for manipulating static and dynamic application's configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrConfigNotFound is being returned when there is no config in the system at all.
Functions ¶
This section is empty.
Types ¶
type Dynamic ¶
type Dynamic struct { // RegisterFrom is switch for register form. If it's true, then // registration form is active and random users from internet // are able to create accounts in the website. RegisterFrom bool `json:"registerForm"` }
Dynamic holds configuration variables for application that can be changed at runtime.
type ReadRepository ¶
type ReadRepository interface { // ReadLatestConfig returns latest blob of bytes with encoded config // as JSON document. // // It can return ErrConfigNotFound. ReadLatestConfig(context.Context) ([]byte, error) }
ReadRepository reads configuration from storage.
type Service ¶
type Service struct { WriteRepository ReadRepository }
Service manages dynamic configuration of system.
func (*Service) Init ¶
Init pushes default dynamic config to the database. If there is already existing dynamic configuration, it does nothing.
func (*Service) Latest ¶
Latest returns the latest current version of dynamic config during the time of read.
func (*Service) PushNewVersion ¶
PushNewVersion pushes new version of dynamic config and make it live immediately.
type Static ¶
type Static struct { // Environment type, which application is run at. // // Can be: TEST (test), DEV (development) or PRD (production). Environment string `envconfig:"env" default:"PRD"` // Host part of the address to listen. Host string `default:"127.0.0.1"` // Port part of the address to listen. Port int32 `default:"8080"` // DatabasePath is path which points to the database file. DatabasePath string `default:"okrzeja.sqlite" split_words:"true"` }
Static holds configuration variables for application that cannot be changed at runtime and are stored in the environmental variables.
func ReadStatic ¶
ReadStatic reads Static configuration from environmental variables.
type WriteRepository ¶
type WriteRepository interface { // WriteConfig writes new version of configuration to the storage. // // It shouldn't purge the current version of config, instead, new // entry should be added to the storage and previous kept in some // kid of archive. WriteConfig(context.Context, WriteRequest) error }
WriteRepository writes config to the internal storage.