Files
gluetun/internal/publicip/state/state.go
2022-06-12 01:11:22 +00:00

38 lines
736 B
Go

package state
import (
"context"
"sync"
"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/publicip/ipinfo"
)
func New(statusApplier StatusApplier,
settings settings.PublicIP,
updateTicker chan<- struct{}) *State {
return &State{
statusApplier: statusApplier,
settings: settings,
updateTicker: updateTicker,
}
}
type State struct {
statusApplier StatusApplier
settings settings.PublicIP
settingsMu sync.RWMutex
ipData ipinfo.Response
ipDataMu sync.RWMutex
updateTicker chan<- struct{}
}
type StatusApplier interface {
ApplyStatus(ctx context.Context, status models.LoopStatus) (
outcome string, err error)
}