mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
EntityStore: Rename ObjectStore to EntityStore (part 2) (#59616)
This commit is contained in:
parent
ab40f8b8a3
commit
14a080ec12
@ -105,7 +105,7 @@ The following toggles require explicitly setting Grafana's [app mode]({{< relref
|
||||
| `export` | Export grafana instance (to git, etc) |
|
||||
| `azureMonitorResourcePickerForMetrics` | New UI for Azure Monitor Metrics Query |
|
||||
| `grpcServer` | Run GRPC server |
|
||||
| `objectStore` | SQL-based object store |
|
||||
| `entityStore` | SQL-based entity store (requires storage flag also) |
|
||||
| `queryLibrary` | Reusable query library |
|
||||
| `accessControlOnCall` | Access control primitives for OnCall |
|
||||
| `nestedFolders` | Enable folder nesting |
|
||||
|
2
go.mod
2
go.mod
@ -203,7 +203,7 @@ require (
|
||||
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect
|
||||
github.com/oklog/run v1.1.0 // indirect
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
|
||||
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
|
@ -65,7 +65,7 @@ export interface FeatureToggles {
|
||||
internationalization?: boolean;
|
||||
topnav?: boolean;
|
||||
grpcServer?: boolean;
|
||||
objectStore?: boolean;
|
||||
entityStore?: boolean;
|
||||
traceqlEditor?: boolean;
|
||||
flameGraph?: boolean;
|
||||
cloudWatchCrossAccountQuerying?: boolean;
|
||||
|
@ -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) {
|
||||
|
@ -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()))
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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{})
|
||||
|
@ -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
|
||||
|
@ -61,7 +61,7 @@ interface ExporterInfo {
|
||||
|
||||
const formats: Array<SelectableValue<string>> = [
|
||||
{ label: 'GIT', value: 'git', description: 'Exports a fresh git repository' },
|
||||
{ label: 'Object store', value: 'objectStore', description: 'Export to the SQL based object store' },
|
||||
{ label: 'Entity store', value: 'entityStore', description: 'Export to the SQL based entity store' },
|
||||
];
|
||||
|
||||
interface Props {
|
||||
@ -173,9 +173,9 @@ export const ExportView = ({ onPathChange }: Props) => {
|
||||
onChange={(v) => setBody({ ...body!, format: v.value! })}
|
||||
/>
|
||||
</Field>
|
||||
{body?.format === 'objectStore' && !config.featureToggles.objectStore && (
|
||||
{body?.format === 'entityStore' && !config.featureToggles.entityStore && (
|
||||
<div>
|
||||
<Alert title="Missing feature flag">Enable the `objectStore` feature flag</Alert>
|
||||
<Alert title="Missing feature flag">Enable the `entityStore` feature flag</Alert>
|
||||
</div>
|
||||
)}
|
||||
{body?.format === 'git' && (
|
||||
|
Loading…
Reference in New Issue
Block a user