chronograf/bolt/dashboards.go

37 lines
808 B
Go
Raw Normal View History

2016-12-09 03:28:40 +00:00
package bolt
import (
"context"
"github.com/boltdb/bolt"
"github.com/influxdata/chronograf"
"github.com/influxdata/chronograf/bolt/internal"
)
var _ chronograf.DashboardsStore = &DashboardsStore{}
type DashboardsStore struct {
client *Client
}
func (s *DashboardsStore) All(ctx context.Context) ([]chronograf.Dashboard, error) {
var srcs []chronograf.Dashboard
if err := s.client.db.View(func(tx *bolt.Tx) error {
if err := tx.Bucket(DashboardBucket).ForEach(func(k, v []byte) error {
var src chonograf.Dashboard
if err := internal.UnmarshalDashboard(v, &src); err != nil {
return err
}
srcs = append(srcs, src)
return nil
}); err != nil {
return err
}
return nil
}); err != nil {
return nil, err
}
return srcs, nil
}