Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
LoadConfig reads in configuration files and environment variables in the following order of priority:
1. environment variables (optional) 2. {path}/config.{env}.yaml (optional, but logs a warning if missing) 3. {path}/config.yaml (mandatory)
An config variable "var.sub_2: value" can be overwritten with an environment variable VAR_SUB_2.
func SetGlobalLogLevel ¶
func SetGlobalLogLevel(level string)
SetGlobalLogLevel updates the log level, panics if log level is unknown.
Types ¶
type AppEnv ¶
AppEnv contains all application-scoped variables.
func NewAppEnv ¶
NewAppEnv creates an AppEnv by loading configuration settings.
Panics if configuration failed to load.
func (*AppEnv) AddService ¶
func (ctx *AppEnv) AddService(service AppService)
type AppService ¶
type AppService interface { // Configure is run when a new app context is created. Use this to load // configuration settings. // // Any error will cause a panic. The app waits for all services to be // configured before calling Init. Configure(env *AppEnv) error // Init is run after all services have been configured. Use this to run // setup that is dependent on other services. // // Any error will cause a panic. The app starts after all initializations // are finished. Init() error // Close is run right before shutdown. The app waits until close resolves. // // Any returned error is logged but will not cause a panic or exit. Close() error // Name returns the name of the service used for logging purposes. Name() string }
AppService instantiates a singleton application service that is created on application boot and shutdown gracefully on application termination.