Chore: Remove bus from live package (#46803)
This commit is contained in:
@@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
|
||||||
"github.com/grafana/grafana/pkg/models"
|
"github.com/grafana/grafana/pkg/models"
|
||||||
"github.com/grafana/grafana/pkg/services/guardian"
|
"github.com/grafana/grafana/pkg/services/guardian"
|
||||||
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type actionType string
|
type actionType string
|
||||||
@@ -39,6 +39,7 @@ type dashboardEvent struct {
|
|||||||
type DashboardHandler struct {
|
type DashboardHandler struct {
|
||||||
Publisher models.ChannelPublisher
|
Publisher models.ChannelPublisher
|
||||||
ClientCount models.ChannelClientCount
|
ClientCount models.ChannelClientCount
|
||||||
|
Store sqlstore.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHandlerForPath called on init
|
// GetHandlerForPath called on init
|
||||||
@@ -62,7 +63,7 @@ func (h *DashboardHandler) OnSubscribe(ctx context.Context, user *models.SignedI
|
|||||||
// make sure can view this dashboard
|
// make sure can view this dashboard
|
||||||
if len(parts) == 2 && parts[0] == "uid" {
|
if len(parts) == 2 && parts[0] == "uid" {
|
||||||
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId}
|
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId}
|
||||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
if err := h.Store.GetDashboard(ctx, &query); err != nil {
|
||||||
logger.Error("Error getting dashboard", "query", query, "error", err)
|
logger.Error("Error getting dashboard", "query", query, "error", err)
|
||||||
return models.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, nil
|
return models.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, nil
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ func (h *DashboardHandler) OnPublish(ctx context.Context, user *models.SignedInU
|
|||||||
return models.PublishReply{}, backend.PublishStreamStatusNotFound, fmt.Errorf("ignore???")
|
return models.PublishReply{}, backend.PublishStreamStatusNotFound, fmt.Errorf("ignore???")
|
||||||
}
|
}
|
||||||
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId}
|
query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId}
|
||||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
if err := h.Store.GetDashboard(ctx, &query); err != nil {
|
||||||
logger.Error("Unknown dashboard", "query", query)
|
logger.Error("Unknown dashboard", "query", query)
|
||||||
return models.PublishReply{}, backend.PublishStreamStatusNotFound, nil
|
return models.PublishReply{}, backend.PublishStreamStatusNotFound, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, r
|
|||||||
dash := &features.DashboardHandler{
|
dash := &features.DashboardHandler{
|
||||||
Publisher: g.Publish,
|
Publisher: g.Publish,
|
||||||
ClientCount: g.ClientCount,
|
ClientCount: g.ClientCount,
|
||||||
|
Store: sqlStore,
|
||||||
}
|
}
|
||||||
g.storage = database.NewStorage(g.SQLStore, g.CacheService)
|
g.storage = database.NewStorage(g.SQLStore, g.CacheService)
|
||||||
g.GrafanaScope.Dashboards = dash
|
g.GrafanaScope.Dashboards = dash
|
||||||
|
|||||||
Reference in New Issue
Block a user