Clean up config package

This commit is contained in:
Daniel 2019-09-20 10:35:35 +02:00
parent e0535421e4
commit 78aa2f3986
5 changed files with 14 additions and 16 deletions

View file

@ -99,12 +99,12 @@ func (s *StorageInterface) Query(q *query.Query, local, internal bool) (*iterato
}
}
go s.processQuery(q, it, opts)
go s.processQuery(it, opts)
return it, nil
}
func (s *StorageInterface) processQuery(q *query.Query, it *iterator.Iterator, opts []*Option) {
func (s *StorageInterface) processQuery(it *iterator.Iterator, opts []*Option) {
sort.Sort(sortableOptions(opts))

View file

@ -9,12 +9,6 @@ import (
var (
validityFlag = abool.NewBool(true)
validityFlagLock sync.RWMutex
tableLock sync.RWMutex
stringTable map[string]string
intTable map[string]int
boolTable map[string]bool
)
type (

View file

@ -20,7 +20,7 @@ var (
// ErrInvalidOptionType is returned by SetConfigOption and SetDefaultConfigOption if given an unsupported option type.
ErrInvalidOptionType = errors.New("invalid option value type")
changedSignal = make(chan struct{}, 0)
changedSignal = make(chan struct{})
)
// Changed signals if any config option was changed.
@ -34,7 +34,7 @@ func Changed() <-chan struct{} {
func triggerChange() {
// must be locked!
close(changedSignal)
changedSignal = make(chan struct{}, 0)
changedSignal = make(chan struct{})
}
// setConfig sets the (prioritized) user defined config.
@ -141,7 +141,7 @@ func setConfigOption(name string, value interface{}, push bool) error {
if err == nil {
resetValidityFlag()
go saveConfig()
go saveConfig() //nolint:errcheck // error is logged
triggerChange()
}

View file

@ -1,3 +1,4 @@
//nolint:goconst,errcheck
package config
import "testing"

View file

@ -39,16 +39,19 @@ func getTypeName(t uint8) string {
// Option describes a configuration option.
type Option struct {
Name string
Key string // category/sub/key
Description string
Name string
Key string // in path format: category/sub/key
Description string
ExpertiseLevel uint8
OptType uint8
RequiresRestart bool
DefaultValue interface{}
ExternalOptType string
ValidationRegex string
RequiresRestart bool
compiledRegex *regexp.Regexp
compiledRegex *regexp.Regexp
}
// Export expors an option to a Record.