grafana/pkg/stores/rethinkdb.go

46 lines
790 B
Go
Raw Normal View History

2014-08-21 15:09:48 -05:00
package stores
import (
"time"
r "github.com/dancannon/gorethink"
2014-10-04 06:33:20 -05:00
"github.com/torkelo/grafana-pro/pkg/log"
2014-08-21 15:09:48 -05:00
)
type rethinkStore struct {
session *r.Session
}
type RethinkCfg struct {
DatabaseName string
}
type Account struct {
Id int `gorethink:"id"`
NextDashboardId int
}
2014-08-21 15:09:48 -05:00
func NewRethinkStore(config *RethinkCfg) *rethinkStore {
log.Info("Initializing rethink storage")
session, err := r.Connect(r.ConnectOpts{
Address: "localhost:28015",
Database: config.DatabaseName,
MaxIdle: 10,
IdleTimeout: time.Second * 10,
})
if err != nil {
2014-10-04 06:33:20 -05:00
log.Error(3, "Failed to connect to rethink database %v", err)
2014-08-21 15:09:48 -05:00
}
2014-09-21 08:01:59 -05:00
createRethinkDBTablesAndIndices(config, session)
2014-08-21 15:09:48 -05:00
return &rethinkStore{
session: session,
}
}
func (self *rethinkStore) Close() {}