Maint: loopstate package used in Openvpn state

This commit is contained in:
Quentin McGaw (desktop)
2021-07-23 20:41:45 +00:00
parent fa6ccb08bd
commit 253310bd1a
16 changed files with 374 additions and 218 deletions

View File

@@ -0,0 +1,38 @@
package loopstate
import (
"sync"
"github.com/qdm12/gluetun/internal/models"
)
type Manager interface {
Locker
Getter
Setter
Applier
}
func New(status models.LoopStatus,
start chan<- struct{}, running <-chan models.LoopStatus,
stop chan<- struct{}, stopped <-chan struct{}) *State {
return &State{
status: status,
start: start,
running: running,
stop: stop,
stopped: stopped,
}
}
type State struct {
loopMu sync.RWMutex
status models.LoopStatus
statusMu sync.RWMutex
start chan<- struct{}
running <-chan models.LoopStatus
stop chan<- struct{}
stopped <-chan struct{}
}