feat: add ability to launch targeted dskit modules in the grafana server CLI command (#74188)

* feat: add ability to launch targeted dskit modules in the grafana server CLI command

This commit adds a ModuleServer and ModuleRunner suitable for launching dskit services and updates the server cli command to use this instead of the full Server. The default behavior is unchanged and will launch the full Grafana server. Individual services are targeted by setting target=comma,seperated,list in the config file.

* require dev mode to target dskit modules

* remove unused type

* replace setting.CommandLineArgs w/setting.Cfg; the caller can deal with calling setting.NewCfg

* Update pkg/server/module_server.go

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>

---------

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
This commit is contained in:
Kristin Laemmert
2023-09-01 08:09:54 -04:00
committed by GitHub
co-authored by Serge Zaitsev
parent 94dd17a936
commit 0de2c9eb96
12 changed files with 321 additions and 50 deletions
-27
View File
@@ -90,30 +90,3 @@ func TestServer_Shutdown(t *testing.T) {
err = <-ch
require.NoError(t, err)
}
type MockModuleService struct {
initFunc func(context.Context) error
runFunc func(context.Context) error
shutdownFunc func(context.Context) error
}
func (m *MockModuleService) Init(ctx context.Context) error {
if m.initFunc != nil {
return m.initFunc(ctx)
}
return nil
}
func (m *MockModuleService) Run(ctx context.Context) error {
if m.runFunc != nil {
return m.runFunc(ctx)
}
return nil
}
func (m *MockModuleService) Shutdown(ctx context.Context) error {
if m.shutdownFunc != nil {
return m.shutdownFunc(ctx)
}
return nil
}