Maint: interface composition for HTTP proxy loop
- Change SetStatus to ApplyStatus - Add Runner interface - Add SettingsGetterSetter alias to state.SettingsGetterSetter
This commit is contained in:
@@ -14,13 +14,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Looper interface {
|
type Looper interface {
|
||||||
Run(ctx context.Context, done chan<- struct{})
|
Runner
|
||||||
SetStatus(ctx context.Context, status models.LoopStatus) (
|
loopstate.Getter
|
||||||
outcome string, err error)
|
loopstate.Applier
|
||||||
GetStatus() (status models.LoopStatus)
|
SettingsGetterSetter
|
||||||
GetSettings() (settings configuration.HTTPProxy)
|
|
||||||
SetSettings(ctx context.Context, settings configuration.HTTPProxy) (
|
|
||||||
outcome string)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type looper struct {
|
type looper struct {
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import (
|
|||||||
"github.com/qdm12/gluetun/internal/constants"
|
"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{}) {
|
func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/configuration"
|
"github.com/qdm12/gluetun/internal/configuration"
|
||||||
|
"github.com/qdm12/gluetun/internal/httpproxy/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type SettingsGetterSetter = state.SettingsGetterSetter
|
||||||
|
|
||||||
func (l *looper) GetSettings() (settings configuration.HTTPProxy) {
|
func (l *looper) GetSettings() (settings configuration.HTTPProxy) {
|
||||||
return l.state.GetSettings()
|
return l.state.GetSettings()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func (l *looper) GetStatus() (status models.LoopStatus) {
|
|||||||
return l.statusManager.GetStatus()
|
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) {
|
outcome string, err error) {
|
||||||
return l.statusManager.ApplyStatus(ctx, status)
|
return l.statusManager.ApplyStatus(ctx, status)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user