impl stubbed out scrape and push
This commit is contained in:
@@ -3,12 +3,18 @@ package config
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"local/storage"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Interval Duration
|
||||
States []State
|
||||
Storage []string
|
||||
|
||||
lock sync.Mutex
|
||||
db storage.DB
|
||||
}
|
||||
|
||||
var live Config
|
||||
@@ -30,6 +36,24 @@ func Refresh() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Get() Config {
|
||||
return live
|
||||
func Get() *Config {
|
||||
return &live
|
||||
}
|
||||
|
||||
func (c *Config) DB() storage.DB {
|
||||
if c.db == nil {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
if c.db == nil {
|
||||
if len(c.Storage) == 0 {
|
||||
c.Storage = []string{storage.MAP.String()}
|
||||
}
|
||||
db, err := storage.New(storage.TypeFromString(c.Storage[0]), c.Storage[1:]...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c.db = db
|
||||
}
|
||||
}
|
||||
return c.db
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user