2016-10-03 19:55:37 +02:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
2016-10-03 19:55:37 +02:00
|
|
|
)
|
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
// Connection interface to use for implementation in e.g. influxdb
|
|
|
|
type Connection interface {
|
|
|
|
// AddNode data for a single node
|
|
|
|
AddNode(nodeID string, node *runtime.Node)
|
|
|
|
AddStatistics(stats *runtime.GlobalStats, time time.Time)
|
2016-12-15 11:10:09 +01:00
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
DeleteNode(deleteAfter time.Duration)
|
2016-10-03 19:55:37 +02:00
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
Close()
|
2016-10-03 19:55:37 +02:00
|
|
|
}
|
2016-12-15 09:52:12 +01:00
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
// Connect function with config to get DB connection interface
|
|
|
|
type Connect func(config interface{}) (Connection, error)
|
2016-10-03 19:55:37 +02:00
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
/*
|
|
|
|
* for selfbinding in use of the package all
|
|
|
|
*/
|
2016-10-03 19:55:37 +02:00
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
var Adapters = map[string]Connect{}
|
2016-10-03 19:55:37 +02:00
|
|
|
|
2017-04-10 18:54:12 +02:00
|
|
|
func AddDatabaseType(name string, n Connect) {
|
|
|
|
Adapters[name] = n
|
2016-10-03 19:55:37 +02:00
|
|
|
}
|