Fix linter errors and update deps

This commit is contained in:
Daniel 2020-10-29 13:58:33 +01:00
parent 3f3305d8c2
commit 8a0c3a077c
9 changed files with 20 additions and 22 deletions

View file

@ -177,7 +177,7 @@ type Option struct {
// been created.
Description string
// Help may hold a long version of the description providing
// assistence with the configuration option.
// assistance with the configuration option.
// Help is considered immutable after the option has
// been created.
Help string

View file

@ -45,7 +45,7 @@ func isAllowedPossibleValue(opt *Option, value interface{}) error {
compareAgainst := val.Value
valueType := reflect.TypeOf(value)
// loading int's from the configuration JSON does not perserve the correct type
// loading int's from the configuration JSON does not preserve the correct type
// as we get float64 instead. Make sure to convert them before.
if reflect.TypeOf(val.Value).ConvertibleTo(valueType) {
compareAgainst = reflect.ValueOf(val.Value).Convert(valueType).Interface()

View file

@ -17,7 +17,7 @@ type Hook interface {
// the underlying storage. A PreGet hookd may be used to
// implement more advanced access control on database keys.
PreGet(dbKey string) error
// UsesPostGet should returnd true if the hook's PostGet
// UsesPostGet should return true if the hook's PostGet
// should be called after loading a database record from
// the underlying storage.
UsesPostGet() bool

View file

@ -21,7 +21,7 @@ var (
printGraphFlag bool
)
// Register registeres a new subsystem. It's like Manager.Register
// Register registers a new subsystem. It's like Manager.Register
// but uses DefaultManager and panics on error.
func Register(id, name, description string, module *modules.Module, configKeySpace string, option *config.Option) {
err := DefaultManager.Register(id, name, description, module, configKeySpace, option)
@ -92,7 +92,7 @@ func prep() error {
func start() error {
// Registration of subsystems is only allowed during
// preperation. Make sure any further call to Register()
// preparation. Make sure any further call to Register()
// panics.
if err := DefaultManager.Start(); err != nil {
return err
@ -104,9 +104,9 @@ func start() error {
}
// PrintGraph prints the subsystem and module graph.
func (reg *Manager) PrintGraph() {
reg.l.RLock()
defer reg.l.RUnlock()
func (mng *Manager) PrintGraph() {
mng.l.RLock()
defer mng.l.RUnlock()
fmt.Println("subsystems dependency graph:")
@ -114,17 +114,17 @@ func (reg *Manager) PrintGraph() {
module.Disable()
// mark roots
for _, sub := range reg.subsys {
for _, sub := range mng.subsys {
sub.module.Enable() // mark as tree root
}
for _, sub := range reg.subsys {
for _, sub := range mng.subsys {
printModuleGraph("", sub.module, true)
}
fmt.Println("\nsubsystem module groups:")
_ = start() // no errors for what we need here
for _, sub := range reg.subsys {
for _, sub := range mng.subsys {
fmt.Printf("├── %s\n", sub.Name)
for _, mod := range sub.Modules[1:] {
fmt.Printf("│ ├── %s\n", mod.Name)

View file

@ -36,7 +36,7 @@ type Manager struct {
runtime *runtime.Registry
}
// NewManager returns a new subsystem manager that registeres
// NewManager returns a new subsystem manager that registers
// itself at rtReg.
func NewManager(rtReg *runtime.Registry) (*Manager, error) {
mng := &Manager{
@ -71,7 +71,7 @@ func (mng *Manager) Start() error {
}
// aggregate all modules dependencies (and the subsystem module itself)
// into the Modules slice. Configuration options form dependened modules
// into the Modules slice. Configuration options form dependent modules
// will be marked using config.SubsystemAnnotation if not already set.
for _, sub := range mng.subsys {
sub.Modules = append(sub.Modules, statusFromModule(sub.module))
@ -118,7 +118,7 @@ func (mng *Manager) Get(keyOrPrefix string) ([]record.Record, error) {
return records, nil
}
// Register registeres a new subsystem. The given option must be a bool option.
// Register registers a new subsystem. The given option must be a bool option.
// Should be called in init() directly after the modules.Register() function.
// The config option must not yet be registered and will be registered for
// you. Pass a nil option to force enable.

View file

@ -28,7 +28,7 @@ type Subsystem struct { //nolint:maligned // not worth the effort
// FailureStatus is the worst failure status that is currently
// set in one of the subsystem's dependencies.
FailureStatus uint8
// ToggleOptionKey holds the key of the configuraiton option
// ToggleOptionKey holds the key of the configuration option
// that is used to completely enable or disable this subsystem.
ToggleOptionKey string
// ExpertiseLevel defines the complexity of the subsystem and is

View file

@ -9,12 +9,10 @@ var (
// DefaultRegistry is the default registry
// that is used by the module-level API.
DefaultRegistry = NewRegistry()
module *modules.Module
)
func init() {
module = modules.Register("runtime", nil, startModule, nil, "database")
modules.Register("runtime", nil, startModule, nil, "database")
}
func startModule() error {

View file

@ -36,7 +36,7 @@ var (
// package but may consider creating a dedicated
// runtime registry on their own. Registry uses
// a radix tree for value providers and their
// choosen database key/prefix.
// chosen database key/prefix.
type Registry struct {
l sync.RWMutex
providers *radix.Tree

View file

@ -43,7 +43,7 @@ func getTestRegistry(t *testing.T) *Registry {
r := NewRegistry()
providers := []testProvider{
testProvider{
{
k: "p1/",
r: []record.Record{
makeTestRecord("p1/f1/v1", "p1.1"),
@ -51,7 +51,7 @@ func getTestRegistry(t *testing.T) *Registry {
makeTestRecord("p1/v3", "p1.3"),
},
},
testProvider{
{
k: "p2/f1",
r: []record.Record{
makeTestRecord("p2/f1/v1", "p2.1"),
@ -104,7 +104,7 @@ func TestRegistryQuery(t *testing.T) {
iter, err := reg.Query(q, true, true)
require.NoError(t, err)
require.NotNil(t, iter)
var records []record.Record
var records []record.Record //nolint:prealloc
for r := range iter.Next {
records = append(records, r)
}