Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶ added in v0.6.14
type Config interface {
Get(format string, args ...any) any
GetBool(format string, args ...any) bool
GetDuration(format string, args ...any) time.Duration
GetFloat64(format string, args ...any) float64
GetInt(format string, args ...any) int
GetInt32(format string, args ...any) int32
GetInt64(format string, args ...any) int64
GetIntSlice(format string, args ...any) []int
GetSizeInBytes(format string, args ...any) uint
GetString(format string, args ...any) string
GetStringMap(format string, args ...any) map[string]any
GetStringMapString(format string, args ...any) map[string]string
GetStringMapStringSlice(format string, args ...any) map[string][]string
GetStringSlice(format string, args ...any) []string
GetTime(format string, args ...any) time.Time
GetUint(format string, args ...any) uint
GetUint8(format string, args ...any) uint8
GetUint16(format string, args ...any) uint16
GetUint32(format string, args ...any) uint32
GetUint64(format string, args ...any) uint64
IsSet(format string, args ...any) bool
}
Config is the read side of the app's configuration, handed to services through the Init context. Every getter takes a format string: with no args it is the key itself, otherwise it is fmt.Sprintf-ed first, so a service reads under its own root - GetInt("%s.connection.max_open", nameutil.ConfigRoot(m.name)) - rather than a hardcoded one. Getters mirror viper's: an absent key reads as the zero value, never an error.
func FromContext ¶
FromContext returns the Config the supervisor wrapped into the Init context. It never returns nil: with no config in the context it returns an empty Config, so every getter yields the zero value - a missing config looks like "all defaults", so a mandatory setting is validated in Init.