EntityStore: Rename ObjectStore to EntityStore (part 2) (#59616)

This commit is contained in:
Ryan McKinley
2022-11-30 17:52:15 -05:00
committed by GitHub
parent ab40f8b8a3
commit 14a080ec12
15 changed files with 45 additions and 45 deletions
+4 -4
View File
@@ -285,11 +285,11 @@ func (hs *HTTPServer) registerRoutes() {
if hs.Features.IsEnabled(featuremgmt.FlagStorage) {
// Will eventually be replaced with the 'object' route
apiRoute.Group("/storage", hs.StorageService.RegisterHTTPRoutes)
}
// Allow HTTP access to the object storage feature (dev only for now)
if hs.Features.IsEnabled(featuremgmt.FlagGrpcServer) {
apiRoute.Group("/object", hs.httpEntityStore.RegisterHTTPRoutes)
}
// Allow HTTP access to the entity storage feature (dev only for now)
if hs.Features.IsEnabled(featuremgmt.FlagEntityStore) {
apiRoute.Group("/entity", hs.httpEntityStore.RegisterHTTPRoutes)
}
if hs.Features.IsEnabled(featuremgmt.FlagPanelTitleSearch) {
+1 -1
View File
@@ -233,7 +233,7 @@ func (ex *StandardExport) HandleRequestExport(c *models.ReqContext) response.Res
switch cfg.Format {
case "dummy":
job, err = startDummyExportJob(cfg, broadcast)
case "objectStore":
case "entityStore":
job, err = startEntityStoreJob(ctx, cfg, broadcast, ex.db, ex.playlistService, ex.store, ex.dashboardsnapshotsService)
case "git":
dir := filepath.Join(ex.dataDir, "export_git", fmt.Sprintf("git_%d", time.Now().Unix()))
+2 -2
View File
@@ -281,8 +281,8 @@ var (
RequiresDevMode: true,
},
{
Name: "objectStore",
Description: "SQL-based object store",
Name: "entityStore",
Description: "SQL-based entity store (requires storage flag also)",
State: FeatureStateAlpha,
RequiresDevMode: true,
},
+3 -3
View File
@@ -203,9 +203,9 @@ const (
// Run GRPC server
FlagGrpcServer = "grpcServer"
// FlagObjectStore
// SQL-based object store
FlagObjectStore = "objectStore"
// FlagEntityStore
// SQL-based entity store (requires storage flag also)
FlagEntityStore = "entityStore"
// FlagTraceqlEditor
// Show the TraceQL editor in the explore page
@@ -18,15 +18,15 @@ import (
// 2. CREATE/UPDATE/DELETE same items to the object store
// 3. Use the object store for all read operations
// This givs us a safe test bed to work with the store but still roll back without any lost work
type objectStoreImpl struct {
sess *session.SessionDB
sqlimpl *Service
objectstore entity.EntityStoreServer
type entityStoreImpl struct {
sess *session.SessionDB
sqlimpl *Service
store entity.EntityStoreServer
}
var _ playlist.Service = &objectStoreImpl{}
var _ playlist.Service = &entityStoreImpl{}
func (s *objectStoreImpl) sync() {
func (s *entityStoreImpl) sync() {
type Info struct {
OrgID int64 `db:"org_id"`
UID string `db:"uid"`
@@ -55,7 +55,7 @@ func (s *objectStoreImpl) sync() {
return
}
body, _ := json.Marshal(dto)
_, _ = s.objectstore.Write(ctx, &entity.WriteEntityRequest{
_, _ = s.store.Write(ctx, &entity.WriteEntityRequest{
GRN: &entity.GRN{
TenantId: info.OrgID,
UID: info.UID,
@@ -66,14 +66,14 @@ func (s *objectStoreImpl) sync() {
}
}
func (s *objectStoreImpl) Create(ctx context.Context, cmd *playlist.CreatePlaylistCommand) (*playlist.Playlist, error) {
func (s *entityStoreImpl) Create(ctx context.Context, cmd *playlist.CreatePlaylistCommand) (*playlist.Playlist, error) {
rsp, err := s.sqlimpl.store.Insert(ctx, cmd)
if err == nil && rsp != nil {
body, err := json.Marshal(cmd)
if err != nil {
return rsp, fmt.Errorf("unable to write playlist to store")
}
_, err = s.objectstore.Write(ctx, &entity.WriteEntityRequest{
_, err = s.store.Write(ctx, &entity.WriteEntityRequest{
GRN: &entity.GRN{
Kind: models.StandardKindPlaylist,
UID: rsp.UID,
@@ -87,14 +87,14 @@ func (s *objectStoreImpl) Create(ctx context.Context, cmd *playlist.CreatePlayli
return rsp, err
}
func (s *objectStoreImpl) Update(ctx context.Context, cmd *playlist.UpdatePlaylistCommand) (*playlist.PlaylistDTO, error) {
func (s *entityStoreImpl) Update(ctx context.Context, cmd *playlist.UpdatePlaylistCommand) (*playlist.PlaylistDTO, error) {
rsp, err := s.sqlimpl.store.Update(ctx, cmd)
if err == nil {
body, err := json.Marshal(cmd)
if err != nil {
return rsp, fmt.Errorf("unable to write playlist to store")
}
_, err = s.objectstore.Write(ctx, &entity.WriteEntityRequest{
_, err = s.store.Write(ctx, &entity.WriteEntityRequest{
GRN: &entity.GRN{
UID: rsp.Uid,
Kind: models.StandardKindPlaylist,
@@ -108,10 +108,10 @@ func (s *objectStoreImpl) Update(ctx context.Context, cmd *playlist.UpdatePlayli
return rsp, err
}
func (s *objectStoreImpl) Delete(ctx context.Context, cmd *playlist.DeletePlaylistCommand) error {
func (s *entityStoreImpl) Delete(ctx context.Context, cmd *playlist.DeletePlaylistCommand) error {
err := s.sqlimpl.store.Delete(ctx, cmd)
if err == nil {
_, err = s.objectstore.Delete(ctx, &entity.DeleteEntityRequest{
_, err = s.store.Delete(ctx, &entity.DeleteEntityRequest{
GRN: &entity.GRN{
UID: cmd.UID,
Kind: models.StandardKindPlaylist,
@@ -128,7 +128,7 @@ func (s *objectStoreImpl) Delete(ctx context.Context, cmd *playlist.DeletePlayli
// Read access is managed entirely by the object store
//------------------------------------------------------
func (s *objectStoreImpl) GetWithoutItems(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.Playlist, error) {
func (s *entityStoreImpl) GetWithoutItems(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.Playlist, error) {
p, err := s.Get(ctx, q) // OrgID is actually picked from the user!
if err != nil {
return nil, err
@@ -141,8 +141,8 @@ func (s *objectStoreImpl) GetWithoutItems(ctx context.Context, q *playlist.GetPl
}, nil
}
func (s *objectStoreImpl) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.PlaylistDTO, error) {
rsp, err := s.objectstore.Read(ctx, &entity.ReadEntityRequest{
func (s *entityStoreImpl) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.PlaylistDTO, error) {
rsp, err := s.store.Read(ctx, &entity.ReadEntityRequest{
GRN: &entity.GRN{
UID: q.UID,
Kind: models.StandardKindPlaylist,
@@ -162,10 +162,10 @@ func (s *objectStoreImpl) Get(ctx context.Context, q *playlist.GetPlaylistByUidQ
return found, err
}
func (s *objectStoreImpl) Search(ctx context.Context, q *playlist.GetPlaylistsQuery) (playlist.Playlists, error) {
func (s *entityStoreImpl) Search(ctx context.Context, q *playlist.GetPlaylistsQuery) (playlist.Playlists, error) {
playlists := make(playlist.Playlists, 0)
rsp, err := s.objectstore.Search(ctx, &entity.EntitySearchRequest{
rsp, err := s.store.Search(ctx, &entity.EntitySearchRequest{
Kind: []string{models.StandardKindPlaylist},
WithBody: true,
Limit: 1000,
@@ -31,11 +31,11 @@ func ProvideService(db db.DB, toggles featuremgmt.FeatureToggles, objserver enti
svc := &Service{store: sqlstore}
// FlagObjectStore is only supported in development mode
if toggles.IsEnabled(featuremgmt.FlagObjectStore) {
impl := &objectStoreImpl{
sqlimpl: svc,
objectstore: objserver,
sess: db.GetSqlxSession(),
if toggles.IsEnabled(featuremgmt.FlagEntityStore) {
impl := &entityStoreImpl{
sqlimpl: svc,
store: objserver,
sess: db.GetSqlxSession(),
}
impl.sync() // load everythign from the existing SQL setup into the new object store
return impl
@@ -18,7 +18,7 @@ func getLatinPathColumn(name string) *migrator.Column {
}
}
func addObjectStorageMigrations(mg *migrator.Migrator) {
func addEntityStoreMigrations(mg *migrator.Migrator) {
grnLength := 256 // len(tenant)~8 + len(kind)!16 + len(kind)~128 = 256
tables := []migrator.Table{}
tables = append(tables, migrator.Table{
@@ -83,8 +83,8 @@ func (*OSSMigrations) AddMigration(mg *Migrator) {
addCommentMigrations(mg)
}
if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagObjectStore) {
addObjectStorageMigrations(mg)
if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagEntityStore) {
addEntityStoreMigrations(mg)
}
}
+1 -1
View File
@@ -489,7 +489,7 @@ var featuresEnabledDuringTests = []string{
featuremgmt.FlagDashboardPreviews,
featuremgmt.FlagDashboardComments,
featuremgmt.FlagPanelTitleSearch,
featuremgmt.FlagObjectStore,
featuremgmt.FlagEntityStore,
}
// InitTestDBWithMigration initializes the test DB given custom migrations.
+1 -1
View File
@@ -11,7 +11,7 @@ import (
func init() { //nolint:gochecknoinits
jsoniter.RegisterTypeEncoder("entity.EntitySearchResult", &searchResultCodec{})
jsoniter.RegisterTypeEncoder("entity.WriteObjectResponse", &writeResponseCodec{})
jsoniter.RegisterTypeEncoder("entity.WriteEntityResponse", &writeResponseCodec{})
jsoniter.RegisterTypeEncoder("entity.ReadEntityResponse", &readResponseCodec{})
jsoniter.RegisterTypeEncoder("entity.Entity", &rawEntityCodec{})
+1 -1
View File
@@ -64,7 +64,7 @@ func createTestContext(t *testing.T) testContext {
dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
EnableFeatureToggles: []string{
featuremgmt.FlagGrpcServer,
featuremgmt.FlagObjectStore,
featuremgmt.FlagEntityStore,
},
AppModeProduction: false, // required for migrations to run
GRPCServerAddress: "127.0.0.1:0", // :0 for choosing the port automatically