Documentation ¶
Index ¶
- Constants
- func Bool(c *Config, name string) bool
- func BoolSafe(c *Config, name string) bool
- func Duration(c *Config, name string) time.Duration
- func DurationSafe(c *Config, name string) time.Duration
- func FloatOrDefault(c *Config, name string, defaultValue float64) float64
- func Int(c *Config, name string) int64
- func IntSafe(c *Config, name string) int64
- func SizeInBytesSafe(c *Config, name string) uint64
- func String(c *Config, name string) string
- func StringSafe(c *Config, name string) string
- func StringSlice(c *Config, name string) []string
- func StringSliceSafe(c *Config, name string) []string
- func Uint(c *Config, name string) uint64
- func Uint32(c *Config, name string) uint32
- func Uint32Safe(c *Config, name string) uint32
- func UintSafe(c *Config, name string) uint64
- type Config
Constants ¶
const ( // EnvPrefix is a prefix of ENV variables related // to storage node configuration. EnvPrefix = "FROSTFS" )
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool reads a configuration value from c by name and casts it to bool.
Panics if the value can not be casted.
func BoolSafe ¶
BoolSafe reads a configuration value from c by name and casts it to bool.
Returns false if the value can not be casted.
func Duration ¶
Duration reads a configuration value from c by name and casts it to time.Duration.
Panics if the value can not be casted.
func DurationSafe ¶
DurationSafe reads a configuration value from c by name and casts it to time.Duration.
Returns 0 if the value can not be casted.
func FloatOrDefault ¶ added in v0.38.0
FloatOrDefault reads a configuration value from c by name and casts it to float64.
Returns defaultValue if the value can not be casted.
func Int ¶
Int reads a configuration value from c by name and casts it to int64.
Panics if the value can not be casted.
func IntSafe ¶
IntSafe reads a configuration value from c by name and casts it to int64.
Returns 0 if the value can not be casted.
func SizeInBytesSafe ¶
SizeInBytesSafe reads a configuration value from c by name and casts it to size in bytes (uint64).
The suffix can be single-letter (b, k, m, g, t) or with an additional b at the end. Spaces between the number and the suffix are allowed. All multipliers are power of 2 (i.e. k is for kibi-byte).
Returns 0 if a value can't be casted.
func String ¶
String reads a configuration value from c by name and casts it to string.
Panics if the value can not be casted.
func StringSafe ¶
StringSafe reads a configuration value from c by name and casts it to string.
Returns "" if the value can not be casted.
func StringSlice ¶
StringSlice reads a configuration value from c by name and casts it to []string.
Panics if the value can not be casted.
func StringSliceSafe ¶
StringSliceSafe reads a configuration value from c by name and casts it to []string.
Returns nil if the value can not be casted.
func Uint ¶
Uint reads a configuration value from c by name and casts it to uint64.
Panics if the value can not be casted.
func Uint32 ¶
Uint32 reads a configuration value from c by name and casts it to uint32.
Panics if the value can not be casted.
func Uint32Safe ¶
Uint32Safe reads a configuration value from c by name and casts it to uint32.
Returns 0 if the value can not be casted.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents a group of named values structured by tree type.
Sub-trees are named configuration sub-sections, leaves are named configuration values. Names are of string type.
func New ¶
New creates a new Config instance.
If file option is provided, configuration values are read from it. Otherwise, Config is a degenerate tree.
func (*Config) SetDefault ¶
SetDefault sets fallback config for missing values.
It supports only one level of nesting and is intended to be used to provide default values.