Make all Store names plural for consistency

pull/5028/head
Jared Scheib 2017-10-24 15:50:11 -07:00
parent a48fb6cda9
commit 30b8d3cdca
18 changed files with 116 additions and 116 deletions

View File

@ -19,7 +19,7 @@ type Client struct {
SourcesStore *SourcesStore
ServersStore *ServersStore
LayoutStore *LayoutStore
LayoutsStore *LayoutsStore
DashboardsStore *DashboardsStore
UsersStore *UsersStore
OrganizationsStore *OrganizationsStore
@ -31,7 +31,7 @@ func NewClient() *Client {
c := &Client{Now: time.Now}
c.SourcesStore = &SourcesStore{client: c}
c.ServersStore = &ServersStore{client: c}
c.LayoutStore = &LayoutStore{
c.LayoutsStore = &LayoutsStore{
client: c,
IDs: &uuid.V4{},
}
@ -67,11 +67,11 @@ func (c *Client) Open(ctx context.Context) error {
return err
}
// Always create Layouts bucket.
if _, err := tx.CreateBucketIfNotExists(LayoutBucket); err != nil {
if _, err := tx.CreateBucketIfNotExists(LayoutsBucket); err != nil {
return err
}
// Always create Dashboards bucket.
if _, err := tx.CreateBucketIfNotExists(DashboardBucket); err != nil {
if _, err := tx.CreateBucketIfNotExists(DashboardsBucket); err != nil {
return err
}
// Always create Users bucket.

View File

@ -12,8 +12,8 @@ import (
// Ensure DashboardsStore implements chronograf.DashboardsStore.
var _ chronograf.DashboardsStore = &DashboardsStore{}
// DashboardBucket is the bolt bucket dashboards are stored in
var DashboardBucket = []byte("Dashoard")
// DashboardsBucket is the bolt bucket dashboards are stored in
var DashboardsBucket = []byte("Dashoard")
// DashboardsStore is the bolt implementation of storing dashboards
type DashboardsStore struct {
@ -62,7 +62,7 @@ func (d *DashboardsStore) Migrate(ctx context.Context) error {
func (d *DashboardsStore) All(ctx context.Context) ([]chronograf.Dashboard, error) {
var srcs []chronograf.Dashboard
if err := d.client.db.View(func(tx *bolt.Tx) error {
if err := tx.Bucket(bucket(DashboardBucket, d.Organization)).ForEach(func(k, v []byte) error {
if err := tx.Bucket(bucket(DashboardsBucket, d.Organization)).ForEach(func(k, v []byte) error {
var src chronograf.Dashboard
if err := internal.UnmarshalDashboard(v, &src); err != nil {
return err
@ -83,7 +83,7 @@ func (d *DashboardsStore) All(ctx context.Context) ([]chronograf.Dashboard, erro
// Add creates a new Dashboard in the DashboardsStore
func (d *DashboardsStore) Add(ctx context.Context, src chronograf.Dashboard) (chronograf.Dashboard, error) {
if err := d.client.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(bucket(DashboardBucket, d.Organization))
b := tx.Bucket(bucket(DashboardsBucket, d.Organization))
id, _ := b.NextSequence()
src.ID = chronograf.DashboardID(id)
@ -114,7 +114,7 @@ func (d *DashboardsStore) Get(ctx context.Context, id chronograf.DashboardID) (c
var src chronograf.Dashboard
if err := d.client.db.View(func(tx *bolt.Tx) error {
strID := strconv.Itoa(int(id))
if v := tx.Bucket(bucket(DashboardBucket, d.Organization)).Get([]byte(strID)); v == nil {
if v := tx.Bucket(bucket(DashboardsBucket, d.Organization)).Get([]byte(strID)); v == nil {
return chronograf.ErrDashboardNotFound
} else if err := internal.UnmarshalDashboard(v, &src); err != nil {
return err
@ -131,7 +131,7 @@ func (d *DashboardsStore) Get(ctx context.Context, id chronograf.DashboardID) (c
func (d *DashboardsStore) Delete(ctx context.Context, dash chronograf.Dashboard) error {
if err := d.client.db.Update(func(tx *bolt.Tx) error {
strID := strconv.Itoa(int(dash.ID))
if err := tx.Bucket(bucket(DashboardBucket, d.Organization)).Delete([]byte(strID)); err != nil {
if err := tx.Bucket(bucket(DashboardsBucket, d.Organization)).Delete([]byte(strID)); err != nil {
return err
}
return nil
@ -146,7 +146,7 @@ func (d *DashboardsStore) Delete(ctx context.Context, dash chronograf.Dashboard)
func (d *DashboardsStore) Update(ctx context.Context, dash chronograf.Dashboard) error {
if err := d.client.db.Update(func(tx *bolt.Tx) error {
// Get an existing dashboard with the same ID.
b := tx.Bucket(bucket(DashboardBucket, d.Organization))
b := tx.Bucket(bucket(DashboardsBucket, d.Organization))
strID := strconv.Itoa(int(dash.ID))
if v := b.Get([]byte(strID)); v == nil {
return chronograf.ErrDashboardNotFound

View File

@ -8,24 +8,24 @@ import (
"github.com/influxdata/chronograf/bolt/internal"
)
// Ensure LayoutStore implements chronograf.LayoutStore.
var _ chronograf.LayoutStore = &LayoutStore{}
// Ensure LayoutsStore implements chronograf.LayoutsStore.
var _ chronograf.LayoutsStore = &LayoutsStore{}
// LayoutBucket is the bolt bucket layouts are stored in
var LayoutBucket = []byte("Layout")
// LayoutsBucket is the bolt bucket layouts are stored in
var LayoutsBucket = []byte("Layout")
// LayoutStore is the bolt implementation to store layouts
type LayoutStore struct {
// LayoutsStore is the bolt implementation to store layouts
type LayoutsStore struct {
client *Client
IDs chronograf.ID
Organization string
}
// All returns all known layouts
func (s *LayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
func (s *LayoutsStore) All(ctx context.Context) ([]chronograf.Layout, error) {
var srcs []chronograf.Layout
if err := s.client.db.View(func(tx *bolt.Tx) error {
if err := tx.Bucket(bucket(LayoutBucket, s.Organization)).ForEach(func(k, v []byte) error {
if err := tx.Bucket(bucket(LayoutsBucket, s.Organization)).ForEach(func(k, v []byte) error {
var src chronograf.Layout
if err := internal.UnmarshalLayout(v, &src); err != nil {
return err
@ -44,10 +44,10 @@ func (s *LayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
}
// Add creates a new Layout in the LayoutStore.
func (s *LayoutStore) Add(ctx context.Context, src chronograf.Layout) (chronograf.Layout, error) {
// Add creates a new Layout in the LayoutsStore.
func (s *LayoutsStore) Add(ctx context.Context, src chronograf.Layout) (chronograf.Layout, error) {
if err := s.client.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket(bucket(LayoutBucket, s.Organization))
b := tx.Bucket(bucket(LayoutsBucket, s.Organization))
id, err := s.IDs.Generate()
if err != nil {
return err
@ -67,14 +67,14 @@ func (s *LayoutStore) Add(ctx context.Context, src chronograf.Layout) (chronogra
return src, nil
}
// Delete removes the Layout from the LayoutStore
func (s *LayoutStore) Delete(ctx context.Context, src chronograf.Layout) error {
// Delete removes the Layout from the LayoutsStore
func (s *LayoutsStore) Delete(ctx context.Context, src chronograf.Layout) error {
_, err := s.Get(ctx, src.ID)
if err != nil {
return err
}
if err := s.client.db.Update(func(tx *bolt.Tx) error {
if err := tx.Bucket(bucket(LayoutBucket, s.Organization)).Delete([]byte(src.ID)); err != nil {
if err := tx.Bucket(bucket(LayoutsBucket, s.Organization)).Delete([]byte(src.ID)); err != nil {
return err
}
return nil
@ -86,10 +86,10 @@ func (s *LayoutStore) Delete(ctx context.Context, src chronograf.Layout) error {
}
// Get returns a Layout if the id exists.
func (s *LayoutStore) Get(ctx context.Context, id string) (chronograf.Layout, error) {
func (s *LayoutsStore) Get(ctx context.Context, id string) (chronograf.Layout, error) {
var src chronograf.Layout
if err := s.client.db.View(func(tx *bolt.Tx) error {
if v := tx.Bucket(bucket(LayoutBucket, s.Organization)).Get([]byte(id)); v == nil {
if v := tx.Bucket(bucket(LayoutsBucket, s.Organization)).Get([]byte(id)); v == nil {
return chronograf.ErrLayoutNotFound
} else if err := internal.UnmarshalLayout(v, &src); err != nil {
return err
@ -103,10 +103,10 @@ func (s *LayoutStore) Get(ctx context.Context, id string) (chronograf.Layout, er
}
// Update a Layout
func (s *LayoutStore) Update(ctx context.Context, src chronograf.Layout) error {
func (s *LayoutsStore) Update(ctx context.Context, src chronograf.Layout) error {
if err := s.client.db.Update(func(tx *bolt.Tx) error {
// Get an existing layout with the same ID.
b := tx.Bucket(bucket(LayoutBucket, s.Organization))
b := tx.Bucket(bucket(LayoutsBucket, s.Organization))
if v := b.Get([]byte(src.ID)); v == nil {
return chronograf.ErrLayoutNotFound
}

View File

@ -81,13 +81,13 @@ func (s *OrganizationsStore) createResources(id uint64, tx *bolt.Tx) error {
return err
}
// Always create Layouts bucket.
orgLayoutBucket := []byte(path.Join(string(LayoutBucket), idStr))
if _, err := tx.CreateBucketIfNotExists(orgLayoutBucket); err != nil {
orgLayoutsBucket := []byte(path.Join(string(LayoutsBucket), idStr))
if _, err := tx.CreateBucketIfNotExists(orgLayoutsBucket); err != nil {
return err
}
// Always create Dashboards bucket.
orgDashboardBucket := []byte(path.Join(string(DashboardBucket), idStr))
if _, err := tx.CreateBucketIfNotExists(orgDashboardBucket); err != nil {
orgDashboardsBucket := []byte(path.Join(string(DashboardsBucket), idStr))
if _, err := tx.CreateBucketIfNotExists(orgDashboardsBucket); err != nil {
return err
}
return nil
@ -106,13 +106,13 @@ func (s *OrganizationsStore) removeResources(id uint64, tx *bolt.Tx) error {
return err
}
// Always create Layouts bucket.
orgLayoutBucket := []byte(path.Join(string(LayoutBucket), idStr))
if err := tx.DeleteBucket(orgLayoutBucket); err != nil {
orgLayoutsBucket := []byte(path.Join(string(LayoutsBucket), idStr))
if err := tx.DeleteBucket(orgLayoutsBucket); err != nil {
return err
}
// Always create Dashboards bucket.
orgDashboardBucket := []byte(path.Join(string(DashboardBucket), idStr))
if err := tx.DeleteBucket(orgDashboardBucket); err != nil {
orgDashboardsBucket := []byte(path.Join(string(DashboardsBucket), idStr))
if err := tx.DeleteBucket(orgDashboardsBucket); err != nil {
return err
}
@ -174,7 +174,7 @@ func (s *OrganizationsStore) appendStores(o *chronograf.Organization) {
client: s.client,
Organization: idStr,
}
o.LayoutStore = &LayoutStore{
o.LayoutsStore = &LayoutsStore{
client: s.client,
Organization: idStr,
IDs: &uuid.V4{},

View File

@ -15,7 +15,7 @@ var orgCmpOptions = cmp.Options{
cmpopts.IgnoreFields(chronograf.Organization{}, "ID"),
cmpopts.IgnoreFields(chronograf.Organization{}, "SourcesStore"),
cmpopts.IgnoreFields(chronograf.Organization{}, "ServersStore"),
cmpopts.IgnoreFields(chronograf.Organization{}, "LayoutStore"),
cmpopts.IgnoreFields(chronograf.Organization{}, "LayoutsStore"),
cmpopts.IgnoreFields(chronograf.Organization{}, "DashboardsStore"),
cmpopts.EquateEmpty(),
}
@ -106,14 +106,14 @@ func TestOrganizationsStore_GetWithName(t *testing.T) {
t.Errorf("%q. OrganizationsStore.Get() ServerssStore.org = %s, want %s", gotOrg, wantOrg)
}
boltLayoutStore, ok := got.LayoutStore.(*bolt.LayoutStore)
boltLayoutsStore, ok := got.LayoutsStore.(*bolt.LayoutsStore)
if !ok {
t.Errorf("got.LayoutStore is not *bolt.LayoutStore")
t.Errorf("got.LayoutsStore is not *bolt.LayoutsStore")
return
}
if gotOrg, wantOrg := boltLayoutStore.Organization, strconv.FormatUint(got.ID, 10); gotOrg != wantOrg {
t.Errorf("%q. OrganizationsStore.Get() LayoutStore.org = %s, want %s", gotOrg, wantOrg)
if gotOrg, wantOrg := boltLayoutsStore.Organization, strconv.FormatUint(got.ID, 10); gotOrg != wantOrg {
t.Errorf("%q. OrganizationsStore.Get() LayoutsStore.org = %s, want %s", gotOrg, wantOrg)
}
boltDashboardsStore, ok := got.DashboardsStore.(*bolt.DashboardsStore)
@ -217,14 +217,14 @@ func TestOrganizationsStore_GetWithID(t *testing.T) {
t.Errorf("%q. OrganizationsStore.Get() ServerssStore.org = %s, want %s", gotOrg, wantOrg)
}
boltLayoutStore, ok := got.LayoutStore.(*bolt.LayoutStore)
boltLayoutsStore, ok := got.LayoutsStore.(*bolt.LayoutsStore)
if !ok {
t.Errorf("got.LayoutStore is not *bolt.LayoutStore")
t.Errorf("got.LayoutsStore is not *bolt.LayoutsStore")
return
}
if gotOrg, wantOrg := boltLayoutStore.Organization, strconv.FormatUint(got.ID, 10); gotOrg != wantOrg {
t.Errorf("%q. OrganizationsStore.Get() LayoutStore.org = %s, want %s", gotOrg, wantOrg)
if gotOrg, wantOrg := boltLayoutsStore.Organization, strconv.FormatUint(got.ID, 10); gotOrg != wantOrg {
t.Errorf("%q. OrganizationsStore.Get() LayoutsStore.org = %s, want %s", gotOrg, wantOrg)
}
boltDashboardsStore, ok := got.DashboardsStore.(*bolt.DashboardsStore)

View File

@ -14,7 +14,7 @@ import (
// AppExt is the the file extension searched for in the directory for layout files
const AppExt = ".json"
// Apps are canned JSON layouts. Implements LayoutStore.
// Apps are canned JSON layouts. Implements LayoutsStore.
type Apps struct {
Dir string // Dir is the directory contained the pre-canned applications.
Load func(string) (chronograf.Layout, error) // Load loads string name and return a Layout
@ -27,7 +27,7 @@ type Apps struct {
}
// NewApps constructs a layout store wrapping a file system directory
func NewApps(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.LayoutStore {
func NewApps(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.LayoutsStore {
return &Apps{
Dir: dir,
Load: loadFile,

View File

@ -10,13 +10,13 @@ import (
//go:generate go-bindata -o bin_gen.go -ignore README|apps|.sh|go -pkg canned .
// BinLayoutStore represents a layout store using data generated by go-bindata
type BinLayoutStore struct {
// BinLayoutsStore represents a layout store using data generated by go-bindata
type BinLayoutsStore struct {
Logger chronograf.Logger
}
// All returns the set of all layouts
func (s *BinLayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
func (s *BinLayoutsStore) All(ctx context.Context) ([]chronograf.Layout, error) {
names := AssetNames()
layouts := make([]chronograf.Layout, len(names))
for i, name := range names {
@ -43,18 +43,18 @@ func (s *BinLayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
return layouts, nil
}
// Add is not support by BinLayoutStore
func (s *BinLayoutStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return chronograf.Layout{}, fmt.Errorf("Add to BinLayoutStore not supported")
// Add is not support by BinLayoutsStore
func (s *BinLayoutsStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return chronograf.Layout{}, fmt.Errorf("Add to BinLayoutsStore not supported")
}
// Delete is not support by BinLayoutStore
func (s *BinLayoutStore) Delete(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("Delete to BinLayoutStore not supported")
// Delete is not support by BinLayoutsStore
func (s *BinLayoutsStore) Delete(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("Delete to BinLayoutsStore not supported")
}
// Get retrieves Layout if `ID` exists.
func (s *BinLayoutStore) Get(ctx context.Context, ID string) (chronograf.Layout, error) {
func (s *BinLayoutsStore) Get(ctx context.Context, ID string) (chronograf.Layout, error) {
layouts, err := s.All(ctx)
if err != nil {
s.Logger.
@ -78,6 +78,6 @@ func (s *BinLayoutStore) Get(ctx context.Context, ID string) (chronograf.Layout,
}
// Update not supported
func (s *BinLayoutStore) Update(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("Update to BinLayoutStore not supported")
func (s *BinLayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
return fmt.Errorf("Update to BinLayoutsStore not supported")
}

View File

@ -732,11 +732,11 @@ type Layout struct {
Cells []Cell `json:"cells"`
}
// LayoutStore stores dashboards and associated Cells
type LayoutStore interface {
// LayoutsStore stores dashboards and associated Cells
type LayoutsStore interface {
// All returns all dashboards in the store
All(context.Context) ([]Layout, error)
// Add creates a new dashboard in the LayoutStore
// Add creates a new dashboard in the LayoutsStore
Add(context.Context, Layout) (Layout, error)
// Delete the dashboard from the store
Delete(context.Context, Layout) error
@ -752,7 +752,7 @@ type Organization struct {
Name string `json:"name"`
SourcesStore SourcesStore
ServersStore ServersStore
LayoutStore LayoutStore
LayoutsStore LayoutsStore
DashboardsStore DashboardsStore
}

View File

@ -6,15 +6,15 @@ import (
"github.com/influxdata/chronograf"
)
// MultiLayoutStore is a Layoutstore that contains multiple LayoutStores
// MultiLayoutsStore is a LayoutsStore that contains multiple LayoutsStores
// The All method will return the set of all Layouts.
// Each method will be tried against the Stores slice serially.
type MultiLayoutStore struct {
Stores []chronograf.LayoutStore
type MultiLayoutsStore struct {
Stores []chronograf.LayoutsStore
}
// All returns the set of all layouts
func (s *MultiLayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
func (s *MultiLayoutsStore) All(ctx context.Context) ([]chronograf.Layout, error) {
all := []chronograf.Layout{}
layoutSet := map[string]chronograf.Layout{}
ok := false
@ -42,8 +42,8 @@ func (s *MultiLayoutStore) All(ctx context.Context) ([]chronograf.Layout, error)
return all, nil
}
// Add creates a new dashboard in the LayoutStore. Tries each store sequentially until success.
func (s *MultiLayoutStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
// Add creates a new dashboard in the LayoutsStore. Tries each store sequentially until success.
func (s *MultiLayoutsStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
var err error
for _, store := range s.Stores {
var l chronograf.Layout
@ -57,7 +57,7 @@ func (s *MultiLayoutStore) Add(ctx context.Context, layout chronograf.Layout) (c
// Delete the dashboard from the store. Searches through all stores to find Layout and
// then deletes from that store.
func (s *MultiLayoutStore) Delete(ctx context.Context, layout chronograf.Layout) error {
func (s *MultiLayoutsStore) Delete(ctx context.Context, layout chronograf.Layout) error {
var err error
for _, store := range s.Stores {
err = store.Delete(ctx, layout)
@ -69,7 +69,7 @@ func (s *MultiLayoutStore) Delete(ctx context.Context, layout chronograf.Layout)
}
// Get retrieves Layout if `ID` exists. Searches through each store sequentially until success.
func (s *MultiLayoutStore) Get(ctx context.Context, ID string) (chronograf.Layout, error) {
func (s *MultiLayoutsStore) Get(ctx context.Context, ID string) (chronograf.Layout, error) {
var err error
for _, store := range s.Stores {
var l chronograf.Layout
@ -82,7 +82,7 @@ func (s *MultiLayoutStore) Get(ctx context.Context, ID string) (chronograf.Layou
}
// Update the dashboard in the store. Searches through each store sequentially until success.
func (s *MultiLayoutStore) Update(ctx context.Context, layout chronograf.Layout) error {
func (s *MultiLayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
var err error
for _, store := range s.Stores {
err = store.Update(ctx, layout)

View File

@ -6,9 +6,9 @@ import (
"github.com/influxdata/chronograf"
)
var _ chronograf.LayoutStore = &LayoutStore{}
var _ chronograf.LayoutsStore = &LayoutsStore{}
type LayoutStore struct {
type LayoutsStore struct {
AddF func(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error)
AllF func(ctx context.Context) ([]chronograf.Layout, error)
DeleteF func(ctx context.Context, layout chronograf.Layout) error
@ -16,22 +16,22 @@ type LayoutStore struct {
UpdateF func(ctx context.Context, layout chronograf.Layout) error
}
func (s *LayoutStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
func (s *LayoutsStore) Add(ctx context.Context, layout chronograf.Layout) (chronograf.Layout, error) {
return s.AddF(ctx, layout)
}
func (s *LayoutStore) All(ctx context.Context) ([]chronograf.Layout, error) {
func (s *LayoutsStore) All(ctx context.Context) ([]chronograf.Layout, error) {
return s.AllF(ctx)
}
func (s *LayoutStore) Delete(ctx context.Context, layout chronograf.Layout) error {
func (s *LayoutsStore) Delete(ctx context.Context, layout chronograf.Layout) error {
return s.DeleteF(ctx, layout)
}
func (s *LayoutStore) Get(ctx context.Context, id string) (chronograf.Layout, error) {
func (s *LayoutsStore) Get(ctx context.Context, id string) (chronograf.Layout, error) {
return s.GetF(ctx, id)
}
func (s *LayoutStore) Update(ctx context.Context, layout chronograf.Layout) error {
func (s *LayoutsStore) Update(ctx context.Context, layout chronograf.Layout) error {
return s.UpdateF(ctx, layout)
}

View File

@ -9,30 +9,30 @@ import (
// LayoutBuilder is responsible for building Layouts
type LayoutBuilder interface {
Build(chronograf.LayoutStore) (*layouts.MultiLayoutStore, error)
Build(chronograf.LayoutsStore) (*layouts.MultiLayoutsStore, error)
}
// MultiLayoutBuilder implements LayoutBuilder and will return a MultiLayoutStore
// MultiLayoutBuilder implements LayoutBuilder and will return a MultiLayoutsStore
type MultiLayoutBuilder struct {
Logger chronograf.Logger
UUID chronograf.ID
CannedPath string
}
// Build will construct a MultiLayoutStore of canned and db-backed personalized
// Build will construct a MultiLayoutsStore of canned and db-backed personalized
// layouts
func (builder *MultiLayoutBuilder) Build(db chronograf.LayoutStore) (*layouts.MultiLayoutStore, error) {
func (builder *MultiLayoutBuilder) Build(db chronograf.LayoutsStore) (*layouts.MultiLayoutsStore, error) {
// These apps are those handled from a directory
apps := canned.NewApps(builder.CannedPath, builder.UUID, builder.Logger)
// These apps are statically compiled into chronograf
binApps := &canned.BinLayoutStore{
binApps := &canned.BinLayoutsStore{
Logger: builder.Logger,
}
// Acts as a front-end to both the bolt layouts, filesystem layouts and binary statically compiled layouts.
// The idea here is that these stores form a hierarchy in which each is tried sequentially until
// the operation has success. So, the database is preferred over filesystem over binary data.
layouts := &layouts.MultiLayoutStore{
Stores: []chronograf.LayoutStore{
layouts := &layouts.MultiLayoutsStore{
Stores: []chronograf.LayoutsStore{
db,
apps,
binApps,

View File

@ -10,7 +10,7 @@ func TestLayoutBuilder(t *testing.T) {
var l server.LayoutBuilder = &server.MultiLayoutBuilder{}
layout, err := l.Build(nil)
if err != nil {
t.Fatalf("MultiLayoutBuilder can't build a MultiLayoutStore: %v", err)
t.Fatalf("MultiLayoutBuilder can't build a MultiLayoutsStore: %v", err)
}
if layout == nil {

View File

@ -11,7 +11,7 @@ func TestService_GetDatabases(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -35,7 +35,7 @@ func TestService_GetDatabases(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,
@ -52,7 +52,7 @@ func TestService_NewDatabase(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -76,7 +76,7 @@ func TestService_NewDatabase(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,
@ -93,7 +93,7 @@ func TestService_DropDatabase(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -117,7 +117,7 @@ func TestService_DropDatabase(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,
@ -134,7 +134,7 @@ func TestService_RetentionPolicies(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -158,7 +158,7 @@ func TestService_RetentionPolicies(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,
@ -175,7 +175,7 @@ func TestService_NewRetentionPolicy(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -199,7 +199,7 @@ func TestService_NewRetentionPolicy(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,
@ -216,7 +216,7 @@ func TestService_UpdateRetentionPolicy(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -240,7 +240,7 @@ func TestService_UpdateRetentionPolicy(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,
@ -257,7 +257,7 @@ func TestService_DropRetentionPolicy(t *testing.T) {
type fields struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
TimeSeriesClient TimeSeriesClient
@ -281,7 +281,7 @@ func TestService_DropRetentionPolicy(t *testing.T) {
h := &Service{
SourcesStore: tt.fields.SourcesStore,
ServersStore: tt.fields.ServersStore,
LayoutStore: tt.fields.LayoutStore,
LayoutsStore: tt.fields.LayoutsStore,
UsersStore: tt.fields.UsersStore,
DashboardsStore: tt.fields.DashboardsStore,
TimeSeriesClient: tt.fields.TimeSeriesClient,

View File

@ -63,7 +63,7 @@ func (s *Service) NewLayout(w http.ResponseWriter, r *http.Request) {
}
var err error
if layout, err = s.LayoutStore.Add(r.Context(), layout); err != nil {
if layout, err = s.LayoutsStore.Add(r.Context(), layout); err != nil {
msg := fmt.Errorf("Error storing layout %v: %v", layout, err)
unknownErrorWithMessage(w, msg, s.Logger)
return
@ -91,7 +91,7 @@ func (s *Service) Layouts(w http.ResponseWriter, r *http.Request) {
}
ctx := r.Context()
layouts, err := s.LayoutStore.All(ctx)
layouts, err := s.LayoutsStore.All(ctx)
if err != nil {
Error(w, http.StatusInternalServerError, "Error loading layouts", s.Logger)
return
@ -123,7 +123,7 @@ func (s *Service) LayoutsID(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
id := httprouter.GetParamFromContext(ctx, "id")
layout, err := s.LayoutStore.Get(ctx, id)
layout, err := s.LayoutsStore.Get(ctx, id)
if err != nil {
Error(w, http.StatusNotFound, fmt.Sprintf("ID %s not found", id), s.Logger)
return
@ -142,7 +142,7 @@ func (s *Service) RemoveLayout(w http.ResponseWriter, r *http.Request) {
ID: id,
}
if err := s.LayoutStore.Delete(ctx, layout); err != nil {
if err := s.LayoutsStore.Delete(ctx, layout); err != nil {
unknownErrorWithMessage(w, err, s.Logger)
return
}
@ -155,7 +155,7 @@ func (s *Service) UpdateLayout(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
id := httprouter.GetParamFromContext(ctx, "id")
_, err := s.LayoutStore.Get(ctx, id)
_, err := s.LayoutsStore.Get(ctx, id)
if err != nil {
Error(w, http.StatusNotFound, fmt.Sprintf("ID %s not found", id), s.Logger)
return
@ -173,7 +173,7 @@ func (s *Service) UpdateLayout(w http.ResponseWriter, r *http.Request) {
return
}
if err := s.LayoutStore.Update(ctx, req); err != nil {
if err := s.LayoutsStore.Update(ctx, req); err != nil {
msg := fmt.Sprintf("Error updating layout ID %s: %v", id, err)
Error(w, http.StatusInternalServerError, msg, s.Logger)
return

View File

@ -126,7 +126,7 @@ func Test_Layouts(t *testing.T) {
// setup mock chronograf.Service and mock logger
lg := &mocks.TestLogger{}
svc := server.Service{
LayoutStore: &mocks.LayoutStore{
LayoutsStore: &mocks.LayoutsStore{
AllF: func(ctx context.Context) ([]chronograf.Layout, error) {
if len(test.allLayouts) == 0 {
return []chronograf.Layout{

View File

@ -14,7 +14,7 @@ type mapping struct {
// GetMappings returns the known mappings of measurements to applications
func (s *Service) GetMappings(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
layouts, err := s.LayoutStore.All(ctx)
layouts, err := s.LayoutsStore.All(ctx)
if err != nil {
Error(w, http.StatusInternalServerError, "Error loading layouts", s.Logger)
return

View File

@ -404,11 +404,11 @@ func openService(ctx context.Context, boltPath string, lBuilder LayoutBuilder, s
os.Exit(1)
}
layouts, err := lBuilder.Build(db.LayoutStore)
layouts, err := lBuilder.Build(db.LayoutsStore)
if err != nil {
logger.
WithField("component", "LayoutStore").
Error("Unable to construct a MultiLayoutStore", err)
WithField("component", "LayoutsStore").
Error("Unable to construct a MultiLayoutsStore", err)
os.Exit(1)
}
@ -434,7 +434,7 @@ func openService(ctx context.Context, boltPath string, lBuilder LayoutBuilder, s
ServersStore: kapacitors,
UsersStore: db.UsersStore,
OrganizationsStore: db.OrganizationsStore,
LayoutStore: layouts,
LayoutsStore: layouts,
DashboardsStore: db.DashboardsStore,
Logger: logger,
UseAuth: useAuth,

View File

@ -13,7 +13,7 @@ import (
type Service struct {
SourcesStore chronograf.SourcesStore
ServersStore chronograf.ServersStore
LayoutStore chronograf.LayoutStore
LayoutsStore chronograf.LayoutsStore
UsersStore chronograf.UsersStore
DashboardsStore chronograf.DashboardsStore
OrganizationsStore chronograf.OrganizationsStore