Persistent server pools (#226)
* GetAllServers with version & timestamp tests * Storage package to sync servers * Use storage Sync to get and use servers
This commit is contained in:
29
internal/storage/storage.go
Normal file
29
internal/storage/storage.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
SyncServers(hardcodedServers models.AllServers) (allServers models.AllServers, err error)
|
||||
}
|
||||
|
||||
type storage struct {
|
||||
osStat func(name string) (os.FileInfo, error)
|
||||
readFile func(filename string) (data []byte, err error)
|
||||
writeFile func(filename string, data []byte, perm os.FileMode) error
|
||||
logger logging.Logger
|
||||
}
|
||||
|
||||
func New(logger logging.Logger) Storage {
|
||||
return &storage{
|
||||
osStat: os.Stat,
|
||||
readFile: ioutil.ReadFile,
|
||||
writeFile: ioutil.WriteFile,
|
||||
logger: logger.WithPrefix("storage: "),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user