chore(all): return concrete types, accept interfaces

- Remove exported interfaces unused locally
- Define interfaces to accept arguments
- Return concrete types, not interfaces
This commit is contained in:
Quentin McGaw
2022-06-11 01:34:30 +00:00
parent 0378fe4a7b
commit 578ef768ab
132 changed files with 594 additions and 935 deletions

View File

@@ -12,18 +12,9 @@ import (
"github.com/qdm12/gluetun/internal/models"
)
var _ Looper = (*Loop)(nil)
type Looper interface {
Runner
loopstate.Getter
loopstate.Applier
SettingsGetSetter
}
type Loop struct {
statusManager loopstate.Manager
state state.Manager
statusManager statusManager
state StateManager
// Other objects
logger Logger
// Internal channels and locks
@@ -34,6 +25,18 @@ type Loop struct {
backoffTime time.Duration
}
type statusManager interface {
GetStatus() (status models.LoopStatus)
SetStatus(status models.LoopStatus)
ApplyStatus(ctx context.Context, status models.LoopStatus) (
outcome string, err error)
}
type StateManager interface {
GetSettings() settings.HTTPProxy
SetSettings(ctx context.Context, settings settings.HTTPProxy) (outcome string)
}
const defaultBackoffTime = 10 * time.Second
func NewLoop(logger Logger, settings settings.HTTPProxy) *Loop {