yanic/database/database.go

36 lines
849 B
Go
Raw Normal View History

2016-10-03 19:55:37 +02:00
package database
import (
"time"
"github.com/FreifunkBremen/yanic/runtime"
2016-10-03 19:55:37 +02:00
)
// Connection interface to use for implementation in e.g. influxdb
type Connection interface {
2017-04-18 01:48:38 +02:00
// InsertNode stores statistics per node
InsertNode(node *runtime.Node)
2017-04-17 20:42:06 +02:00
// InsertLink stores statistics per link
InsertLink(*runtime.Link, time.Time)
2017-04-18 01:48:38 +02:00
// InsertGlobals stores global statistics
InsertGlobals(*runtime.GlobalStats, time.Time)
2017-04-17 20:42:06 +02:00
// PruneNodes prunes historical per-node data
PruneNodes(deleteAfter time.Duration)
2016-10-03 19:55:37 +02:00
2017-04-17 20:42:06 +02:00
// Close closes the database connection
Close()
2016-10-03 19:55:37 +02:00
}
2016-12-15 09:52:12 +01: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-17 20:42:06 +02:00
// Adapters is the list of registered database adapters
var Adapters = map[string]Connect{}
2016-10-03 19:55:37 +02:00
2017-04-17 20:42:06 +02:00
func RegisterAdapter(name string, n Connect) {
Adapters[name] = n
2016-10-03 19:55:37 +02:00
}