mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
f9163351fd
* add bundle registry service to avoid dependency cycles * move user support bundle collector to user service * move usage stat bundle implementation to usage stats * add info for background service * fix remaining imports * whitespace
33 lines
919 B
Go
33 lines
919 B
Go
package bundleregistry
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/services/supportbundles"
|
|
)
|
|
|
|
// Service is the service that registers support bundle collectors.
|
|
type Service struct {
|
|
collectors map[string]supportbundles.Collector
|
|
log log.Logger
|
|
}
|
|
|
|
// NewService creates a new support bundle collector register service.
|
|
func ProvideService() *Service {
|
|
return &Service{
|
|
collectors: make(map[string]supportbundles.Collector),
|
|
log: log.New("support-bundle-collector-registry"),
|
|
}
|
|
}
|
|
|
|
func (s *Service) RegisterSupportItemCollector(collector supportbundles.Collector) {
|
|
if _, ok := s.collectors[collector.UID]; ok {
|
|
s.log.Warn("Support bundle collector with the same UID already registered", "uid", collector.UID)
|
|
}
|
|
|
|
s.collectors[collector.UID] = collector
|
|
}
|
|
|
|
func (s *Service) Collectors() map[string]supportbundles.Collector {
|
|
return s.collectors
|
|
}
|