Configuration package (#369)
This commit is contained in:
@@ -6,9 +6,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/gluetun/internal/storage"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
)
|
||||
@@ -18,8 +18,8 @@ type Looper interface {
|
||||
RunRestartTicker(ctx context.Context, wg *sync.WaitGroup)
|
||||
GetStatus() (status models.LoopStatus)
|
||||
SetStatus(status models.LoopStatus) (outcome string, err error)
|
||||
GetSettings() (settings settings.Updater)
|
||||
SetSettings(settings settings.Updater) (outcome string)
|
||||
GetSettings() (settings configuration.Updater)
|
||||
SetSettings(settings configuration.Updater) (outcome string)
|
||||
}
|
||||
|
||||
type looper struct {
|
||||
@@ -44,7 +44,7 @@ type looper struct {
|
||||
|
||||
const defaultBackoffTime = 5 * time.Second
|
||||
|
||||
func NewLooper(settings settings.Updater, currentServers models.AllServers,
|
||||
func NewLooper(settings configuration.Updater, currentServers models.AllServers,
|
||||
storage storage.Storage, setAllServers func(allServers models.AllServers),
|
||||
client *http.Client, logger logging.Logger) Looper {
|
||||
loggerWithPrefix := logger.WithPrefix("updater: ")
|
||||
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
)
|
||||
|
||||
type state struct {
|
||||
status models.LoopStatus
|
||||
settings settings.Updater
|
||||
settings configuration.Updater
|
||||
statusMu sync.RWMutex
|
||||
periodMu sync.RWMutex
|
||||
}
|
||||
@@ -69,13 +69,13 @@ func (l *looper) SetStatus(status models.LoopStatus) (outcome string, err error)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *looper) GetSettings() (settings settings.Updater) {
|
||||
func (l *looper) GetSettings() (settings configuration.Updater) {
|
||||
l.state.periodMu.RLock()
|
||||
defer l.state.periodMu.RUnlock()
|
||||
return l.state.settings
|
||||
}
|
||||
|
||||
func (l *looper) SetSettings(settings settings.Updater) (outcome string) {
|
||||
func (l *looper) SetSettings(settings configuration.Updater) (outcome string) {
|
||||
l.state.periodMu.Lock()
|
||||
defer l.state.periodMu.Unlock()
|
||||
settingsUnchanged := reflect.DeepEqual(settings, l.state.settings)
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/settings"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/network"
|
||||
)
|
||||
@@ -18,7 +18,7 @@ type Updater interface {
|
||||
|
||||
type updater struct {
|
||||
// configuration
|
||||
options settings.Updater
|
||||
options configuration.Updater
|
||||
|
||||
// state
|
||||
servers models.AllServers
|
||||
@@ -31,7 +31,7 @@ type updater struct {
|
||||
client network.Client
|
||||
}
|
||||
|
||||
func New(settings settings.Updater, httpClient *http.Client,
|
||||
func New(settings configuration.Updater, httpClient *http.Client,
|
||||
currentServers models.AllServers, logger logging.Logger) Updater {
|
||||
if len(settings.DNSAddress) == 0 {
|
||||
settings.DNSAddress = "1.1.1.1"
|
||||
|
||||
Reference in New Issue
Block a user