From 29fef40f2671d305a133fe5d3235407e369f1903 Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Wed, 2 Aug 2023 09:25:55 -0400 Subject: [PATCH] Chore: Move backgroundsvcs and usagestatssvcs to registry (#72692) --- contribute/backend/services.md | 4 ++-- pkg/modules/registry/registry.go | 2 +- .../backgroundsvcs/background_services.go | 0 .../backgroundsvcs/background_services_test.go | 0 pkg/{server => registry}/backgroundsvcs/runner.go | 0 pkg/{server => registry}/backgroundsvcs/runner_test.go | 0 .../usagestatssvcs/usage_stats_providers_registry.go | 0 pkg/server/wire.go | 4 ++-- pkg/server/wireexts_oss.go | 4 ++-- 9 files changed, 7 insertions(+), 7 deletions(-) rename pkg/{server => registry}/backgroundsvcs/background_services.go (100%) rename pkg/{server => registry}/backgroundsvcs/background_services_test.go (100%) rename pkg/{server => registry}/backgroundsvcs/runner.go (100%) rename pkg/{server => registry}/backgroundsvcs/runner_test.go (100%) rename pkg/{server => registry}/usagestatssvcs/usage_stats_providers_registry.go (100%) diff --git a/contribute/backend/services.md b/contribute/backend/services.md index 79b61f4c5ad..e36f0780afe 100644 --- a/contribute/backend/services.md +++ b/contribute/backend/services.md @@ -107,7 +107,7 @@ func InitializeForTest(cla setting.CommandLineArgs, opts Options, apiOpts api.Se ## Background services -A background service runs in the background of the lifecycle between Grafana startup and shutdown. To run your service in the background, it must satisfy the `registry.BackgroundService` interface. Pass it through to the `NewBackgroundServiceRegistry` call in the [ProvideBackgroundServiceRegistry](/pkg/server/backgroundsvcs/background_services.go) function to register it. +A background service runs in the background of the lifecycle between Grafana startup and shutdown. To run your service in the background, it must satisfy the `registry.BackgroundService` interface. Pass it through to the `NewBackgroundServiceRegistry` call in the [ProvideBackgroundServiceRegistry](/pkg/registry/backgroundsvcs/background_services.go) function to register it. You can see an example implementation above of the Run method. @@ -131,7 +131,7 @@ There's a [wireexts_oss.go](/pkg/server/wireexts_oss.go) that has the `wireinjec Similarly, there's a wireexts_enterprise.go file in the Enterprise source code repository where other service implementations can be overridden/be registered. -To extend an OSS background service, create a specific background interface for that type and inject that type to [ProvideBackgroundServiceRegistry](/pkg/server/backgroundsvcs/background_services.go) instead of the concrete type. Then add a wire binding for that interface in [wireexts_oss.go](/pkg/server/wireexts_oss.go) and in the enterprise wireexts file. +To extend an OSS background service, create a specific background interface for that type and inject that type to [ProvideBackgroundServiceRegistry](/pkg/registry/backgroundsvcs/background_services.go) instead of the concrete type. Then add a wire binding for that interface in [wireexts_oss.go](/pkg/server/wireexts_oss.go) and in the enterprise wireexts file. ## Methods diff --git a/pkg/modules/registry/registry.go b/pkg/modules/registry/registry.go index 094fffcf463..3b870348f13 100644 --- a/pkg/modules/registry/registry.go +++ b/pkg/modules/registry/registry.go @@ -7,7 +7,7 @@ import ( "github.com/grafana/grafana/pkg/api" "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/modules" - "github.com/grafana/grafana/pkg/server/backgroundsvcs" + "github.com/grafana/grafana/pkg/registry/backgroundsvcs" grafanaapiserver "github.com/grafana/grafana/pkg/services/grafana-apiserver" "github.com/grafana/grafana/pkg/services/provisioning" "github.com/grafana/grafana/pkg/services/secrets/kvstore/migrations" diff --git a/pkg/server/backgroundsvcs/background_services.go b/pkg/registry/backgroundsvcs/background_services.go similarity index 100% rename from pkg/server/backgroundsvcs/background_services.go rename to pkg/registry/backgroundsvcs/background_services.go diff --git a/pkg/server/backgroundsvcs/background_services_test.go b/pkg/registry/backgroundsvcs/background_services_test.go similarity index 100% rename from pkg/server/backgroundsvcs/background_services_test.go rename to pkg/registry/backgroundsvcs/background_services_test.go diff --git a/pkg/server/backgroundsvcs/runner.go b/pkg/registry/backgroundsvcs/runner.go similarity index 100% rename from pkg/server/backgroundsvcs/runner.go rename to pkg/registry/backgroundsvcs/runner.go diff --git a/pkg/server/backgroundsvcs/runner_test.go b/pkg/registry/backgroundsvcs/runner_test.go similarity index 100% rename from pkg/server/backgroundsvcs/runner_test.go rename to pkg/registry/backgroundsvcs/runner_test.go diff --git a/pkg/server/usagestatssvcs/usage_stats_providers_registry.go b/pkg/registry/usagestatssvcs/usage_stats_providers_registry.go similarity index 100% rename from pkg/server/usagestatssvcs/usage_stats_providers_registry.go rename to pkg/registry/usagestatssvcs/usage_stats_providers_registry.go diff --git a/pkg/server/wire.go b/pkg/server/wire.go index 22a33edce4f..eef20923adb 100644 --- a/pkg/server/wire.go +++ b/pkg/server/wire.go @@ -33,8 +33,8 @@ import ( "github.com/grafana/grafana/pkg/modules" moduleRegistry "github.com/grafana/grafana/pkg/modules/registry" pluginDashboards "github.com/grafana/grafana/pkg/plugins/manager/dashboards" + "github.com/grafana/grafana/pkg/registry/backgroundsvcs" "github.com/grafana/grafana/pkg/registry/corekind" - "github.com/grafana/grafana/pkg/server/backgroundsvcs" "github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/accesscontrol/acimpl" "github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol" @@ -65,7 +65,7 @@ import ( "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/folder" "github.com/grafana/grafana/pkg/services/folder/folderimpl" - "github.com/grafana/grafana/pkg/services/grafana-apiserver" + grafanaapiserver "github.com/grafana/grafana/pkg/services/grafana-apiserver" "github.com/grafana/grafana/pkg/services/grpcserver" grpccontext "github.com/grafana/grafana/pkg/services/grpcserver/context" "github.com/grafana/grafana/pkg/services/grpcserver/interceptors" diff --git a/pkg/server/wireexts_oss.go b/pkg/server/wireexts_oss.go index 1a679f50288..5498d8e1c75 100644 --- a/pkg/server/wireexts_oss.go +++ b/pkg/server/wireexts_oss.go @@ -8,8 +8,8 @@ import ( "github.com/grafana/grafana/pkg/plugins" "github.com/grafana/grafana/pkg/registry" - "github.com/grafana/grafana/pkg/server/backgroundsvcs" - "github.com/grafana/grafana/pkg/server/usagestatssvcs" + "github.com/grafana/grafana/pkg/registry/backgroundsvcs" + "github.com/grafana/grafana/pkg/registry/usagestatssvcs" "github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/accesscontrol/acimpl" "github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"