Chore: Add Usage stats providers registry (#48357)

* add usage stats providers

* migrate thumbnails service to `registry.ProvidesUsageStats`

* snake -> camel

* lint fix

* migrate accesscontrol to `registry.ProvidesUsageStats`

* add accesscontrol to usage stats providers registry

* fix test

* added a note about errors
This commit is contained in:
Artur Wierzbicki
2022-04-28 13:06:49 +04:00
committed by GitHub
parent ff23f78b51
commit 736be74128
13 changed files with 123 additions and 39 deletions
+12
View File
@@ -29,6 +29,18 @@ type BackgroundService interface {
Run(ctx context.Context) error
}
// UsageStatsProvidersRegistry provides services sharing their usage stats
type UsageStatsProvidersRegistry interface {
GetServices() []ProvidesUsageStats
}
// ProvidesUsageStats is an interface for services that share their usage stats
type ProvidesUsageStats interface {
// GetUsageStats is called on a schedule by the UsageStatsService
// Any errors occurring during usage stats collection should be collected and logged within the provider.
GetUsageStats(ctx context.Context) map[string]interface{}
}
// DatabaseMigrator allows the caller to add migrations to
// the migrator passed as argument
type DatabaseMigrator interface {