Documentation
¶
Index ¶
- Constants
- Variables
- func Changed() <-chan struct{}
- func JSONToMap(jsonData []byte) (map[string]interface{}, error)
- func MapToJSON(mapData map[string]interface{}) ([]byte, error)
- func Register(option *Option) error
- func SetConfigOption(name string, value interface{}) error
- func SetDefaultConfig(m map[string]interface{}) error
- func SetDefaultConfigOption(name string, value interface{}) error
- type BoolOption
- type ConfigStorageInterface
- func (s *ConfigStorageInterface) Delete(key string) error
- func (s *ConfigStorageInterface) Get(key string) (record.Record, error)
- func (s *ConfigStorageInterface) Put(r record.Record) error
- func (s *ConfigStorageInterface) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)
- func (s *ConfigStorageInterface) ReadOnly() bool
- type IntOption
- type Option
- type StringArrayOption
- type StringOption
Constants ¶
const ( OptTypeString uint8 = 1 OptTypeStringArray uint8 = 2 OptTypeInt uint8 = 3 OptTypeBool uint8 = 4 ExpertiseLevelUser uint8 = 1 ExpertiseLevelExpert uint8 = 2 ExpertiseLevelDeveloper uint8 = 3 )
Variable Type IDs for frontend Identification. Use ExternalOptType for extended types in the frontend.
Variables ¶
var ( // ErrInvalidJSON is returned by SetConfig and SetDefaultConfig if they receive invalid json. ErrInvalidJSON = errors.New("json string invalid") // ErrInvalidOptionType is returned by SetConfigOption and SetDefaultConfigOption if given an unsupported option type. ErrInvalidOptionType = errors.New("invalid option value type") )
var (
// Concurrent makes concurrency safe get methods available.
Concurrent = &safe{}
)
var ( // ErrIncompleteCall is return when RegisterOption is called with empty mandatory values. ErrIncompleteCall = errors.New("could not register config option: all fields, except for the validationRegex are mandatory") )
Functions ¶
func SetConfigOption ¶
SetConfigOption sets a single value in the (prioritized) user defined config.
func SetDefaultConfig ¶
SetDefaultConfig sets the (fallback) default config.
func SetDefaultConfigOption ¶
SetDefaultConfigOption sets a single value in the (fallback) default config.
Types ¶
type BoolOption ¶
type BoolOption func() bool
BoolOption defines the returned function by GetAsBool.
func GetAsBool ¶
func GetAsBool(name string, fallback bool) BoolOption
GetAsBool returns a function that returns the wanted int with high performance.
type ConfigStorageInterface ¶
type ConfigStorageInterface struct {
storage.InjectBase
}
ConfigStorageInterface provices a storage.Interface to the configuration manager.
func (*ConfigStorageInterface) Delete ¶
func (s *ConfigStorageInterface) Delete(key string) error
Delete deletes a record from the database.
func (*ConfigStorageInterface) Get ¶
func (s *ConfigStorageInterface) Get(key string) (record.Record, error)
Get returns a database record.
func (*ConfigStorageInterface) Put ¶
func (s *ConfigStorageInterface) Put(r record.Record) error
Put stores a record in the database.
func (*ConfigStorageInterface) Query ¶
func (s *ConfigStorageInterface) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)
Query returns a an iterator for the supplied query.
func (*ConfigStorageInterface) ReadOnly ¶
func (s *ConfigStorageInterface) ReadOnly() bool
ReadOnly returns whether the database is read only.
type Option ¶
type Option struct { Name string Key string // category/sub/key Description string ExpertiseLevel uint8 OptType uint8 DefaultValue interface{} ExternalOptType string ValidationRegex string // contains filtered or unexported fields }
Option describes a configuration option.
type StringArrayOption ¶
type StringArrayOption func() []string
StringArrayOption defines the returned function by GetAsStringArray.
func GetAsStringArray ¶
func GetAsStringArray(name string, fallback []string) StringArrayOption
GetAsStringArray returns a function that returns the wanted string with high performance.
type StringOption ¶
type StringOption func() string
StringOption defines the returned function by GetAsString.
func GetAsString ¶
func GetAsString(name string, fallback string) StringOption
GetAsString returns a function that returns the wanted string with high performance.