Documentation ¶
Overview ¶
Package onlineconf reads configuration files generated by OnlineConf.
It opens indexed CDB files and maps them in the memory. If OnlineConf modifies them then they are automatically reopened.
Index ¶
- Variables
- func GetBool(path string, d ...bool) bool
- func GetBoolIfExists(path string) (bool, bool)
- func GetInt(path string, d ...int) int
- func GetIntIfExists(path string) (int, bool)
- func GetString(path string, d ...string) string
- func GetStringIfExists(path string) (string, bool)
- func GetStrings(path string, defaultValue []string) []string
- func GetStruct(path string, value interface{}) (bool, error)
- func Initialize(newConfigDir string)
- func SetOutput(w io.Writer)
- type Module
- func (m *Module) GetBool(path string, d ...bool) bool
- func (m *Module) GetBoolIfExists(path string) (bool, bool)
- func (m *Module) GetInt(path string, d ...int) int
- func (m *Module) GetIntIfExists(path string) (int, bool)
- func (m *Module) GetString(path string, d ...string) string
- func (m *Module) GetStringIfExists(path string) (string, bool)
- func (m *Module) GetStrings(path string, defaultValue []string) []string
- func (m *Module) GetStruct(path string, value interface{}) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ErrFormatIsNotJSON = errors.New("format is not JSON")
Functions ¶
func GetBool ¶ added in v1.1.0
GetBool reads an bool value of a named parameter from the module "TREE". It returns this value if the parameter exists and is a bool. In the other case it panics unless default value is provided in the second argument.
func GetBoolIfExists ¶ added in v1.1.0
GetBoolIfExists reads an bool value of a named parameter from the module "TREE". It returns this value and the boolean true if the parameter exists and is a bool. In the other case it returns the boolean false and 0.
func GetInt ¶
GetInt reads an integer value of a named parameter from the module "TREE". It returns this value if the parameter exists and is an integer. In the other case it panics unless default value is provided in the second argument.
func GetIntIfExists ¶
GetIntIfExists reads an integer value of a named parameter from the module "TREE". It returns this value and the boolean true if the parameter exists and is an integer. In the other case it returns the boolean false and 0.
func GetString ¶
GetString reads a string value of a named parameter from the module "TREE". It returns this value if the parameter exists and is a string. In the other case it panics unless default value is provided in the second argument.
func GetStringIfExists ¶
GetStringIfExists reads a string value of a named parameter from the module "TREE". It returns the boolean true if the parameter exists and is a string. In the other case it returns the boolean false and an empty string.
func GetStrings ¶ added in v1.2.0
GetStrings reads a []string value of a named parameter from the module "TREE". It returns this value if the parameter exists and is a comma-separated string or JSON array. In the other case it returns a default value provided in the second argument.
func GetStruct ¶ added in v1.2.0
GetStruct reads a structured value of a named parameter from the module "TREE". It stores this value in the value pointed by the value argument and returns true if the parameter exists and was unmarshaled successfully. In the case of error or if the parameter is not exists, the function doesn't touch the value argument, so you can safely pass a default value as the value argument and completely ignore return values of this function. A value is unmarshaled from JSON using json.Unmarshal and is cached internally until the configuration is updated, so be careful to not modify values returned by a reference. Experimental: this function can be modified or removed without any notice.
func Initialize ¶ added in v1.1.0
func Initialize(newConfigDir string)
Initialize sets config directory for onlineconf modules. Default value is "/usr/local/etc/onlineconf"
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) GetBool ¶ added in v1.1.0
GetBool reads an bool value of a named parameter from the module. It returns this value if the parameter exists and is a bool. In the other case it panics unless default value is provided in the second argument.
func (*Module) GetBoolIfExists ¶ added in v1.1.0
GetBoolIfExists reads an integer value of a named parameter from the module. It returns this value and the boolean true if the parameter exists and is an bool. In the other case it returns the boolean false and 0.
func (*Module) GetInt ¶
GetInt reads an integer value of a named parameter from the module. It returns this value if the parameter exists and is an integer. In the other case it panics unless default value is provided in the second argument.
func (*Module) GetIntIfExists ¶
GetIntIfExists reads an integer value of a named parameter from the module. It returns this value and the boolean true if the parameter exists and is an integer. In the other case it returns the boolean false and 0.
func (*Module) GetString ¶
GetString reads a string value of a named parameter from the module. It returns this value if the parameter exists and is a string. In the other case it panics unless default value is provided in the second argument.
func (*Module) GetStringIfExists ¶
GetStringIfExists reads a string value of a named parameter from the module. It returns the boolean true if the parameter exists and is a string. In the other case it returns the boolean false and an empty string.
func (*Module) GetStrings ¶ added in v1.2.0
GetStrings reads a []string value of a named parameter from the module. It returns this value if the parameter exists and is a comma-separated string or JSON array. In the other case it returns a default value provided in the second argument.
func (*Module) GetStruct ¶ added in v1.2.0
GetStruct reads a structured value of a named parameter from the module. It stores this value in the value pointed by the value argument and returns true if the parameter exists and was unmarshaled successfully. In the case of error or if the parameter is not exists, the method doesn't touch the value argument, so you can safely pass a default value as the value argument and completely ignore return values of this method. A value is unmarshaled from JSON using json.Unmarshal and is cached internally until the configuration is updated, so be careful to not modify values returned by a reference. Experimental: this method can be modified or removed without any notice.