mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Clean up config package
This commit is contained in:
parent
e0535421e4
commit
78aa2f3986
5 changed files with 14 additions and 16 deletions
|
@ -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))
|
||||
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//nolint:goconst,errcheck
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue