diff --git a/internal/httpproxy/loop.go b/internal/httpproxy/loop.go index 01fb0ff3..c7c01201 100644 --- a/internal/httpproxy/loop.go +++ b/internal/httpproxy/loop.go @@ -14,13 +14,10 @@ import ( ) type Looper interface { - Run(ctx context.Context, done chan<- struct{}) - SetStatus(ctx context.Context, status models.LoopStatus) ( - outcome string, err error) - GetStatus() (status models.LoopStatus) - GetSettings() (settings configuration.HTTPProxy) - SetSettings(ctx context.Context, settings configuration.HTTPProxy) ( - outcome string) + Runner + loopstate.Getter + loopstate.Applier + SettingsGetterSetter } type looper struct { diff --git a/internal/httpproxy/run.go b/internal/httpproxy/run.go index 10ac9bbd..0025d83f 100644 --- a/internal/httpproxy/run.go +++ b/internal/httpproxy/run.go @@ -7,6 +7,10 @@ import ( "github.com/qdm12/gluetun/internal/constants" ) +type Runner interface { + Run(ctx context.Context, done chan<- struct{}) +} + func (l *looper) Run(ctx context.Context, done chan<- struct{}) { defer close(done) diff --git a/internal/httpproxy/settings.go b/internal/httpproxy/settings.go index 4d75b504..576ab488 100644 --- a/internal/httpproxy/settings.go +++ b/internal/httpproxy/settings.go @@ -4,8 +4,11 @@ import ( "context" "github.com/qdm12/gluetun/internal/configuration" + "github.com/qdm12/gluetun/internal/httpproxy/state" ) +type SettingsGetterSetter = state.SettingsGetterSetter + func (l *looper) GetSettings() (settings configuration.HTTPProxy) { return l.state.GetSettings() } diff --git a/internal/httpproxy/status.go b/internal/httpproxy/status.go index 1d40920b..c0ff3bd8 100644 --- a/internal/httpproxy/status.go +++ b/internal/httpproxy/status.go @@ -10,7 +10,7 @@ func (l *looper) GetStatus() (status models.LoopStatus) { return l.statusManager.GetStatus() } -func (l *looper) SetStatus(ctx context.Context, status models.LoopStatus) ( +func (l *looper) ApplyStatus(ctx context.Context, status models.LoopStatus) ( outcome string, err error) { return l.statusManager.ApplyStatus(ctx, status) }