Files
grafana/pkg/server/service.go
Sofia Papagiannaki 402572c580 Add ConfigProvider and modify quota.Service to use it (#109395)
* Add config provider and integrate with wire setup

* Refactor quota service to use config provider for configuration management

* Enhance OSSConfigProvider to include logging and update ProvideService to return an error. Refactor server initialization to handle potential errors from config provider. Remove unnecessary wire binding for OSSConfigProvider.

* Update CODEOWNERS to include the configprovider package under the grafana-backend-services-squad.

* Refactor quota service initialization to include context in multiple service providers. Update tests and service implementations to ensure proper context handling during service creation.
2025-08-12 09:42:10 +03:00

46 lines
960 B
Go

package server
import (
"context"
"github.com/grafana/dskit/services"
"github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/setting"
)
type coreService struct {
*services.BasicService
cfg *setting.Cfg
opts Options
apiOpts api.ServerOptions
server *Server
}
func NewService(cfg *setting.Cfg, opts Options, apiOpts api.ServerOptions) (*coreService, error) {
s := &coreService{
opts: opts,
apiOpts: apiOpts,
cfg: cfg,
}
s.BasicService = services.NewBasicService(s.start, s.running, s.stop)
return s, nil
}
func (s *coreService) start(ctx context.Context) error {
serv, err := Initialize(ctx, s.cfg, s.opts, s.apiOpts)
if err != nil {
return err
}
s.server = serv
return s.server.Init()
}
func (s *coreService) running(_ context.Context) error {
return s.server.Run()
}
func (s *coreService) stop(failureReason error) error {
return s.server.Shutdown(context.Background(), failureReason.Error())
}