chore(updater): internal/updater/loop subpackage

- Do not export updater interface
- Export updater struct
- Define local interfaces where needed
- More restrictive updater loop interface in http control server
- Inject `Updater` into updater loop as an interface
This commit is contained in:
Quentin McGaw
2022-05-28 16:03:59 +00:00
parent 991d75a1d0
commit 292813831d
10 changed files with 45 additions and 51 deletions

View File

@@ -6,12 +6,20 @@ import (
"net/http"
"strings"
"github.com/qdm12/gluetun/internal/updater"
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/models"
)
type UpdaterLooper interface {
GetStatus() (status models.LoopStatus)
SetStatus(ctx context.Context, status models.LoopStatus) (
outcome string, err error)
SetSettings(settings settings.Updater) (outcome string)
}
func newUpdaterHandler(
ctx context.Context,
looper updater.Looper,
looper UpdaterLooper,
warner warner) http.Handler {
return &updaterHandler{
ctx: ctx,
@@ -22,7 +30,7 @@ func newUpdaterHandler(
type updaterHandler struct {
ctx context.Context //nolint:containedctx
looper updater.Looper
looper UpdaterLooper
warner warner
}