Maint: dns package state rework

- Interface composition with loopstate interfaces
- Use loopstate.Manager
- Create dns/state package for handling settings
This commit is contained in:
Quentin McGaw (laptop)
2021-07-24 18:34:55 +00:00
parent 3f1fb52fcb
commit 7479974d79
7 changed files with 130 additions and 216 deletions

View File

@@ -0,0 +1,33 @@
package state
import (
"sync"
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/loopstate"
)
var _ Manager = (*State)(nil)
type Manager interface {
SettingsGetterSetter
}
func New(statusApplier loopstate.Applier,
settings configuration.DNS,
updateTicker chan<- struct{}) *State {
return &State{
statusApplier: statusApplier,
settings: settings,
updateTicker: updateTicker,
}
}
type State struct {
statusApplier loopstate.Applier
settings configuration.DNS
settingsMu sync.RWMutex
updateTicker chan<- struct{}
}