server

package
v11.1.4-modfix Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Server defines the main entrypoints to Grafana and the Grafana CLI, as well as test environments. OSS and Enterprise-specific build tags are used in this package to control wire dependencies for each build.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInstrumentationService

func NewInstrumentationService(log log.Logger, cfg *setting.Cfg) (*instrumentationService, error)

func NewService

func NewService(cfg *setting.Cfg, opts Options, apiOpts api.ServerOptions) (*coreService, error)

Types

type ModuleRunner

type ModuleRunner struct {
	Cfg              *setting.Cfg
	SettingsProvider setting.Provider
	Features         featuremgmt.FeatureToggles
}

ModuleRunner is a simplified version of Runner that is used in the grafana server target command. It has a minimal set of dependencies required to launch background/dskit services.

func NewModuleRunner

func NewModuleRunner(cfg *setting.Cfg, settingsProvider setting.Provider,
	features featuremgmt.FeatureToggles,
) ModuleRunner

type ModuleServer

type ModuleServer struct {
	// contains filtered or unexported fields
}

ModuleServer is responsible for managing the lifecycle of dskit services. The ModuleServer has the minimal set of dependencies to launch dskit services, but it can be used to launch the entire Grafana server.

func NewModule

func NewModule(opts Options, apiOpts api.ServerOptions, features featuremgmt.FeatureToggles, cfg *setting.Cfg) (*ModuleServer, error)

NewModule returns an instance of a ModuleServer, responsible for managing dskit modules (services).

func (*ModuleServer) Run

func (s *ModuleServer) Run() error

Run initializes and starts services. This will block until all services have exited. To initiate shutdown, call the Shutdown method in another goroutine.

func (*ModuleServer) Shutdown

func (s *ModuleServer) Shutdown(ctx context.Context, reason string) error

Shutdown initiates Grafana graceful shutdown. This shuts down all running background services. Since Run blocks Shutdown supposed to be run from a separate goroutine.

type Options

type Options struct {
	HomePath    string
	PidFile     string
	Version     string
	Commit      string
	BuildBranch string
	Listener    net.Listener
}

Options contains parameters for the New function.

type Runner

type Runner struct {
	Cfg               *setting.Cfg
	SQLStore          db.DB
	SettingsProvider  setting.Provider
	Features          featuremgmt.FeatureToggles
	EncryptionService encryption.Internal
	SecretsService    *manager.SecretsService
	SecretsMigrator   secrets.Migrator
	UserService       user.Service
}

func NewRunner

func NewRunner(cfg *setting.Cfg, sqlStore db.DB, settingsProvider setting.Provider,
	encryptionService encryption.Internal, features featuremgmt.FeatureToggles,
	secretsService *manager.SecretsService, secretsMigrator secrets.Migrator,
	userService user.Service,
) Runner

type Server

type Server struct {
	HTTPServer *api.HTTPServer
	// contains filtered or unexported fields
}

Server is responsible for managing the lifecycle of services. This is the core Server implementation which starts the entire Grafana server. Use ModuleServer to launch specific modules.

func New

func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
	provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry,
	usageStatsProvidersRegistry registry.UsageStatsProvidersRegistry, statsCollectorService *statscollector.Service,
	promReg prometheus.Registerer,
) (*Server, error)

New returns a new instance of Server.

func (*Server) Init

func (s *Server) Init() error

Init initializes the server and its services.

func (*Server) Run

func (s *Server) Run() error

Run initializes and starts services. This will block until all services have exited. To initiate shutdown, call the Shutdown method in another goroutine.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context, reason string) error

Shutdown initiates Grafana graceful shutdown. This shuts down all running background services. Since Run blocks Shutdown supposed to be run from a separate goroutine.

type TestEnv

type TestEnv struct {
	Server              *Server
	SQLStore            db.DB
	Cfg                 *setting.Cfg
	NotificationService *notifications.NotificationServiceMock
	GRPCServer          grpcserver.Provider
	PluginRegistry      registry.Service
	HTTPClientProvider  httpclient.Provider
	OAuthTokenService   *oauthtokentest.Service
	RequestMiddleware   web.Middleware
	FeatureToggles      featuremgmt.FeatureToggles
}

func ProvideTestEnv

func ProvideTestEnv(
	server *Server,
	db db.DB,
	cfg *setting.Cfg,
	ns *notifications.NotificationServiceMock,
	grpcServer grpcserver.Provider,
	pluginRegistry registry.Service,
	httpClientProvider httpclient.Provider,
	oAuthTokenService *oauthtokentest.Service,
	featureMgmt featuremgmt.FeatureToggles,
) (*TestEnv, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL