#45498: hook up entity events service to http server

pull/47712/head
Artur Wierzbicki 3 years ago
parent 6282f2a04c
commit 43c98820ae
  1. 10
      pkg/api/dashboard.go
  2. 5
      pkg/api/http_server.go
  3. 2
      pkg/server/wire.go

@ -20,6 +20,7 @@ import (
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/alerting"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/entityevents"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/web"
@ -361,6 +362,15 @@ func (hs *HTTPServer) postDashboard(c *models.ReqContext, cmd models.SaveDashboa
dashboard, err := hs.dashboardService.SaveDashboard(alerting.WithUAEnabled(ctx, hs.Cfg.UnifiedAlerting.IsEnabled()), dashItem, allowUiUpdate)
if dashboard != nil {
if err := hs.entityEventsService.Save(ctx, entityevents.SaveActionCmd{
Grn: fmt.Sprintf("database/%d/dashboards/%s", dashboard.OrgId, dashboard.Uid),
EventType: entityevents.EntityEventTypeUpdate,
}); err != nil {
hs.log.Warn("failed to save dashboard entity event", "uid", dashboard.Uid, "error", err)
}
}
if hs.Live != nil {
// Tell everyone listening that the dashboard changed
if dashboard == nil {

@ -40,6 +40,7 @@ import (
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/datasources/permissions"
"github.com/grafana/grafana/pkg/services/encryption"
"github.com/grafana/grafana/pkg/services/entityevents"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/hooks"
"github.com/grafana/grafana/pkg/services/ldap"
@ -149,6 +150,7 @@ type HTTPServer struct {
DashboardsnapshotsService *dashboardsnapshots.Service
PluginSettings *pluginSettings.Service
AvatarCacheServer *avatar.AvatarCacheServer
entityEventsService entityevents.Service
}
type ServerOptions struct {
@ -180,7 +182,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
dashboardProvisioningService dashboards.DashboardProvisioningService, folderService dashboards.FolderService,
datasourcePermissionsService permissions.DatasourcePermissionsService, alertNotificationService *alerting.AlertNotificationService,
dashboardsnapshotsService *dashboardsnapshots.Service, commentsService *comments.Service, pluginSettings *pluginSettings.Service,
avatarCacheServer *avatar.AvatarCacheServer,
avatarCacheServer *avatar.AvatarCacheServer, entityEventsService entityevents.Service,
) (*HTTPServer, error) {
web.Env = cfg.Env
m := web.New()
@ -254,6 +256,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
PluginSettings: pluginSettings,
permissionServices: permissionsServices,
AvatarCacheServer: avatarCacheServer,
entityEventsService: entityEventsService,
}
if hs.Listener != nil {
hs.log.Debug("Using provided listener")

@ -5,6 +5,7 @@ package server
import (
"github.com/google/wire"
"github.com/grafana/grafana/pkg/services/entityevents"
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana/pkg/api"
@ -147,6 +148,7 @@ var wireBasicSet = wire.NewSet(
postgres.ProvideService,
mysql.ProvideService,
mssql.ProvideService,
entityevents.ProvideService,
httpclientprovider.New,
wire.Bind(new(httpclient.Provider), new(*sdkhttpclient.Provider)),
serverlock.ProvideService,

Loading…
Cancel
Save