From 1464092a69ea29b4de808a15e038d73596ff7b0e Mon Sep 17 00:00:00 2001 From: Martin Geno Date: Fri, 19 Jan 2018 04:31:33 +0100 Subject: [PATCH] [BUGFIX] after database refactory --- cmd/config.go | 7 +++---- cmd/import.go | 2 +- cmd/serve.go | 2 +- database/all/internal.go | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index b7b184b..ff145c2 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -21,10 +21,9 @@ type Config struct { } var ( - configPath string - collector *respond.Collector - connections database.Connection - nodes *runtime.Nodes + configPath string + collector *respond.Collector + nodes *runtime.Nodes ) func loadConfig() *Config { diff --git a/cmd/import.go b/cmd/import.go index 47fee2a..643fa18 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -29,7 +29,7 @@ var importCmd = &cobra.Command{ log.Println("importing RRD from", path) for ds := range rrd.Read(path) { - connections.InsertGlobals( + allDatabase.Conn.InsertGlobals( &runtime.GlobalStats{ Nodes: uint32(ds.Nodes), Clients: uint32(ds.Clients), diff --git a/cmd/serve.go b/cmd/serve.go index 89df9f2..8fe5b5f 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -54,7 +54,7 @@ var serveCmd = &cobra.Command{ time.Sleep(delay) } - collector = respond.NewCollector(connections, nodes, config.Respondd.Sites, config.Respondd.Interfaces, config.Respondd.Port) + collector = respond.NewCollector(allDatabase.Conn, nodes, config.Respondd.Sites, config.Respondd.Interfaces, config.Respondd.Port) collector.Start(config.Respondd.CollectInterval.Duration) defer collector.Close() } diff --git a/database/all/internal.go b/database/all/internal.go index 6731454..cf42fcf 100644 --- a/database/all/internal.go +++ b/database/all/internal.go @@ -7,12 +7,12 @@ import ( "github.com/FreifunkBremen/yanic/database" ) -var conn database.Connection +var Conn database.Connection var wg = sync.WaitGroup{} var quit chan struct{} func Start(config database.Config) (err error) { - conn, err = Connect(config.Connection) + Conn, err = Connect(config.Connection) if err != nil { return } @@ -25,7 +25,7 @@ func Start(config database.Config) (err error) { func Close() { close(quit) wg.Wait() - conn.Close() + Conn.Close() quit = nil } @@ -35,7 +35,7 @@ func deleteWorker(deleteInterval time.Duration, deleteAfter time.Duration) { for { select { case <-ticker.C: - conn.PruneNodes(deleteAfter) + Conn.PruneNodes(deleteAfter) case <-quit: ticker.Stop() wg.Done()