Skip to content

Commit

Permalink
first cut of dskit-ification of entity store
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCech committed Jul 5, 2023
1 parent 3d1f114 commit b43a9bc
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 235 deletions.
5 changes: 3 additions & 2 deletions pkg/modules/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ const (
KubernetesRegistration string = "kubernetes-registration"
Kubernetes string = "kubernetes"
KubernetesClientset string = "kubernetes-clientset"
EntityStore string = "entity-store"

Provisioning string = "provisioning"
)

var DependencyMap = map[string][]string{
CertGenerator: {},

HTTPServer: {CertGenerator},
HTTPServer: {CertGenerator, EntityStore},

KubernetesAPIServer: {CertGenerator},
KubernetesAPIServer: {CertGenerator, EntityStore},
KubernetesRegistration: {KubernetesAPIServer},
KubernetesClientset: {KubernetesRegistration},
Kubernetes: {KubernetesClientset},
Expand Down
3 changes: 3 additions & 0 deletions pkg/modules/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/grafana/grafana/pkg/services/k8s/apiserver"
"github.com/grafana/grafana/pkg/services/k8s/client"
"github.com/grafana/grafana/pkg/services/provisioning"
"github.com/grafana/grafana/pkg/services/store/entity"
)

type Registry interface{}
Expand All @@ -27,6 +28,7 @@ func ProvideRegistry(
httpServer *api.HTTPServer,
provisioning *provisioning.ProvisioningServiceImpl,
coreGRDRegistry *coregrd.Registry,
entityService entity.EntityStoreService,
) *registry {
return NewRegistry(
moduleManager,
Expand All @@ -36,6 +38,7 @@ func ProvideRegistry(
httpServer,
provisioning,
coreGRDRegistry,
entityService,
)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/server/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import (
"github.com/grafana/grafana/pkg/services/star/starimpl"
"github.com/grafana/grafana/pkg/services/stats/statsimpl"
"github.com/grafana/grafana/pkg/services/store"
"github.com/grafana/grafana/pkg/services/store/entity"
entityDB "github.com/grafana/grafana/pkg/services/store/entity/db"
"github.com/grafana/grafana/pkg/services/store/entity/httpentitystore"
"github.com/grafana/grafana/pkg/services/store/entity/sqlstash"
Expand Down Expand Up @@ -343,6 +344,8 @@ var wireBasicSet = wire.NewSet(
kind.ProvideService, // The registry of known kinds
entityDB.ProvideEntityDB,
sqlstash.ProvideSQLEntityServer,
wire.Bind(new(entity.EntityStoreServer), new(*sqlstash.EntityServer)),
wire.Bind(new(entity.EntityStoreService), new(*sqlstash.EntityServer)),
resolver.ProvideEntityReferenceResolver,
httpentitystore.ProvideHTTPEntityStore,
teamimpl.ProvideService,
Expand Down
187 changes: 0 additions & 187 deletions pkg/services/playlist/playlistimpl/entity_store.go

This file was deleted.

18 changes: 2 additions & 16 deletions pkg/services/playlist/playlistimpl/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/grafana/grafana/pkg/infra/db"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/playlist"
"github.com/grafana/grafana/pkg/services/store/entity"
)

type Service struct {
Expand All @@ -15,7 +14,7 @@ type Service struct {

var _ playlist.Service = &Service{}

func ProvideService(db db.DB, toggles featuremgmt.FeatureToggles, objserver entity.EntityStoreServer) playlist.Service {
func ProvideService(db db.DB, toggles featuremgmt.FeatureToggles) playlist.Service {
var sqlstore store

// 🐢🐢🐢 pick the store
Expand All @@ -28,20 +27,7 @@ func ProvideService(db db.DB, toggles featuremgmt.FeatureToggles, objserver enti
db: db,
}
}
svc := &Service{store: sqlstore}

// FlagObjectStore is only supported in development mode
if false && 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
}

return svc
return &Service{store: sqlstore}
}

func (s *Service) Create(ctx context.Context, cmd *playlist.CreatePlaylistCommand) (*playlist.Playlist, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/services/store/entity/db/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func ProvideEntityDB(db db.DB, cfg *setting.Cfg) (EntityDB, error) {
return nil, fmt.Errorf("invalid host specifier '%s': %w", dbHost, err)
}


connectionString := fmt.Sprintf(
"user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", // sslcert=%s sslkey=%s sslrootcert=%s",
dbUser, dbPass, addr.Host, addr.Port, dbName, dbSslMode, // ss.dbCfg.ClientCertPath, ss.dbCfg.ClientKeyPath, ss.dbCfg.CaCertPath
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/store/entity/httpentitystore/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type httpEntityStore struct {
kinds kind.KindRegistry
}

func ProvideHTTPEntityStore(store entity.EntityStoreServer, kinds kind.KindRegistry) HTTPEntityStore {
func ProvideHTTPEntityStore(store entity.EntityStoreService, kinds kind.KindRegistry) HTTPEntityStore {
return &httpEntityStore{
store: store,
log: log.New("http-entity-store"),
Expand Down
15 changes: 15 additions & 0 deletions pkg/services/store/entity/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package entity

import (
"github.com/grafana/dskit/services"
)

type EntityStoreService interface {
services.NamedService
EntityStoreServer
}

type EntityStoreAdminService interface {
services.NamedService
EntityStoreAdminServer
}

0 comments on commit b43a9bc

Please sign in to comment.