2022-02-22 01:47:42 -06:00
|
|
|
package comments
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-10-19 08:02:15 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
2022-04-12 11:30:50 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
2022-09-19 02:54:37 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/annotations"
|
2022-02-22 01:47:42 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/comments/commentmodel"
|
2022-05-17 13:52:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
2022-02-22 01:47:42 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
|
|
"github.com/grafana/grafana/pkg/services/live"
|
2022-08-16 07:24:57 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
2022-02-22 01:47:42 -06:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Service struct {
|
|
|
|
cfg *setting.Cfg
|
|
|
|
live *live.GrafanaLive
|
2022-10-19 08:02:15 -05:00
|
|
|
sqlStore db.DB
|
2022-02-22 01:47:42 -06:00
|
|
|
storage Storage
|
|
|
|
permissions *commentmodel.PermissionChecker
|
2022-08-16 07:24:57 -05:00
|
|
|
userService user.Service
|
2022-02-22 01:47:42 -06:00
|
|
|
}
|
|
|
|
|
2022-10-19 08:02:15 -05:00
|
|
|
func ProvideService(cfg *setting.Cfg, store db.DB, live *live.GrafanaLive,
|
2022-05-17 13:52:22 -05:00
|
|
|
features featuremgmt.FeatureToggles, accessControl accesscontrol.AccessControl,
|
2022-09-19 02:54:37 -05:00
|
|
|
dashboardService dashboards.DashboardService, userService user.Service, annotationsRepo annotations.Repository) *Service {
|
2022-02-22 01:47:42 -06:00
|
|
|
s := &Service{
|
|
|
|
cfg: cfg,
|
|
|
|
live: live,
|
|
|
|
sqlStore: store,
|
|
|
|
storage: &sqlStorage{
|
|
|
|
sql: store,
|
|
|
|
},
|
2022-09-19 02:54:37 -05:00
|
|
|
permissions: commentmodel.NewPermissionChecker(store, features, accessControl, dashboardService, annotationsRepo),
|
2022-08-16 07:24:57 -05:00
|
|
|
userService: userService,
|
2022-02-22 01:47:42 -06:00
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run Service.
|
|
|
|
func (s *Service) Run(ctx context.Context) error {
|
|
|
|
<-ctx.Done()
|
|
|
|
return ctx.Err()
|
|
|
|
}
|