fix(storage): only log warning if flushing merged servers to file fails

This commit is contained in:
Quentin McGaw
2025-11-17 19:04:13 +00:00
parent ad8b0657cb
commit b2859d5a06
6 changed files with 37 additions and 22 deletions

View File

@@ -13,18 +13,20 @@ type Storage struct {
// the embedded JSON file on every call to the
// SyncServers method.
hardcodedServers models.AllServers
logger Infoer
logger Logger
filepath string
}
type Infoer interface {
type Logger interface {
Info(s string)
Warn(s string)
}
// New creates a new storage and reads the servers from the
// embedded servers file and the file on disk.
// Passing an empty filepath disables writing servers to a file.
func New(logger Infoer, filepath string) (storage *Storage, err error) {
// Passing an empty filepath disables the reading and writing of
// servers.
func New(logger Logger, filepath string) (storage *Storage, err error) {
// A unit test prevents any error from being returned
// and ensures all providers are part of the servers returned.
hardcodedServers, _ := parseHardcodedServers()