Previews: refactor (#47728)

* #44449: return standard thumb service even if auth setup fails

* #44449: remove dashboardPreviewsScheduler feature flag

* #44449: externalize dashboardPreviews config

* #44449: disable previews by default

* #44449: rename logger

* #44449: dashboardPreviewsAdmin feature requires dev mode

* #44449: retrigger CII
This commit is contained in:
Artur Wierzbicki
2022-04-25 01:55:10 +04:00
committed by GitHub
parent 70a7b73839
commit 2e599643f6
9 changed files with 94 additions and 32 deletions
+4
View File
@@ -439,6 +439,8 @@ type Cfg struct {
// Query history
QueryHistoryEnabled bool
DashboardPreviews DashboardPreviewsSettings
}
type CommandLineArgs struct {
@@ -1001,6 +1003,8 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
cfg.readDataSourcesSettings()
cfg.DashboardPreviews = readDashboardPreviewsSettings(iniFile)
if VerifyEmailEnabled && !cfg.Smtp.Enabled {
cfg.Logger.Warn("require_email_validation is enabled but smtp is disabled")
}
+31
View File
@@ -0,0 +1,31 @@
package setting
import (
"time"
"gopkg.in/ini.v1"
)
type DashboardPreviewsSettings struct {
SchedulerInterval time.Duration
MaxCrawlDuration time.Duration
RenderingTimeout time.Duration
CrawlThreadCount uint32
}
func readDashboardPreviewsSettings(iniFile *ini.File) DashboardPreviewsSettings {
maxThreadCount := uint32(20)
s := DashboardPreviewsSettings{}
previewsCrawlerSection := iniFile.Section("dashboard_previews.crawler")
s.CrawlThreadCount = uint32(previewsCrawlerSection.Key("thread_count").MustUint(6))
if s.CrawlThreadCount > maxThreadCount {
s.CrawlThreadCount = maxThreadCount
}
s.SchedulerInterval = previewsCrawlerSection.Key("scheduler_interval").MustDuration(12 * time.Hour)
s.MaxCrawlDuration = previewsCrawlerSection.Key("max_crawl_duration").MustDuration(1 * time.Hour)
s.RenderingTimeout = previewsCrawlerSection.Key("rendering_timeout").MustDuration(20 * time.Second)
return s
}