yanic/database/database.go
2017-04-17 20:48:46 +02:00

33 lines
790 B
Go

package database
import (
"time"
"github.com/FreifunkBremen/yanic/runtime"
)
// Connection interface to use for implementation in e.g. influxdb
type Connection interface {
// AddNode stores data of a single node
AddNode(nodeID string, node *runtime.Node)
// AddStatistics stores global statistics
AddStatistics(stats *runtime.GlobalStats, time time.Time)
// PruneNodes prunes historical per-node data
PruneNodes(deleteAfter time.Duration)
// Close closes the database connection
Close()
}
// Connect function with config to get DB connection interface
type Connect func(config interface{}) (Connection, error)
// Adapters is the list of registered database adapters
var Adapters = map[string]Connect{}
func RegisterAdapter(name string, n Connect) {
Adapters[name] = n
}