marshal time.Duration as json string

This commit is contained in:
glidea
2025-05-06 16:00:59 +08:00
parent 8f32e427d4
commit 278cb662de
8 changed files with 86 additions and 26 deletions

View File

@@ -66,14 +66,14 @@ func (c *Config) From(app *config.App) {
c.Scrapers = make([]scraper.Config, len(app.Scrape.Sources))
for i := range app.Scrape.Sources {
c.Scrapers[i] = scraper.Config{
Past: app.Scrape.Past,
Past: time.Duration(app.Scrape.Past),
Name: app.Scrape.Sources[i].Name,
Interval: app.Scrape.Sources[i].Interval,
Interval: time.Duration(app.Scrape.Sources[i].Interval),
Labels: model.Labels{},
}
c.Scrapers[i].Labels.FromMap(app.Scrape.Sources[i].Labels)
if c.Scrapers[i].Interval <= 0 {
c.Scrapers[i].Interval = app.Scrape.Interval
c.Scrapers[i].Interval = time.Duration(app.Scrape.Interval)
}
if app.Scrape.Sources[i].RSS != nil {
c.Scrapers[i].RSS = &scraper.ScrapeSourceRSS{

View File

@@ -55,7 +55,7 @@ const maxPast = 15 * 24 * time.Hour
func (c *Config) Validate() error {
if c.Past <= 0 {
c.Past = 3 * timeutil.Day
c.Past = timeutil.Day
}
if c.Past > maxPast {
c.Past = maxPast