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

@@ -36,15 +36,15 @@ func (l *Loop) RunRestartTicker(ctx context.Context, done chan<- struct{}) {
status := l.GetStatus()
if status == constants.Running {
if err := l.updateFiles(ctx); err != nil {
l.state.SetStatus(constants.Crashed)
l.statusManager.SetStatus(constants.Crashed)
l.logger.Error(err.Error())
l.logger.Warn("skipping Unbound restart due to failed files update")
continue
}
}
_, _ = l.ApplyStatus(ctx, constants.Stopped)
_, _ = l.ApplyStatus(ctx, constants.Running)
_, _ = l.statusManager.ApplyStatus(ctx, constants.Stopped)
_, _ = l.statusManager.ApplyStatus(ctx, constants.Running)
settings := l.GetSettings()
timer.Reset(settings.UpdatePeriod)