feat(master): POLL_INTERVAL, poller wiring and version picker in the UI (#9)
This commit is contained in:
@@ -28,11 +28,17 @@ type Config struct {
|
||||
// UpdateTimeout bounds how long one webhook request waits for its auto
|
||||
// jobs (UPDATE_TIMEOUT, default 5m).
|
||||
UpdateTimeout time.Duration
|
||||
// PollInterval is the time between registry polling cycles
|
||||
// (POLL_INTERVAL, default 6h).
|
||||
PollInterval time.Duration
|
||||
}
|
||||
|
||||
// defaultUpdateTimeout is used when UPDATE_TIMEOUT is unset.
|
||||
const defaultUpdateTimeout = 5 * time.Minute
|
||||
|
||||
// defaultPollInterval is used when POLL_INTERVAL is unset.
|
||||
const defaultPollInterval = 6 * time.Hour
|
||||
|
||||
// Load reads and validates the master configuration, failing fast on
|
||||
// anything missing so a half-configured master never starts.
|
||||
func Load() (*Config, error) {
|
||||
@@ -50,6 +56,7 @@ func Load() (*Config, error) {
|
||||
LogLevel: getenvDefault("LOG_LEVEL", "info"),
|
||||
UpdaterAPIKey: os.Getenv("UPDATER_API_KEY"),
|
||||
UpdateTimeout: defaultUpdateTimeout,
|
||||
PollInterval: defaultPollInterval,
|
||||
}
|
||||
for _, r := range []struct{ name, value string }{
|
||||
{"DATABASE_URL", cfg.DatabaseURL},
|
||||
@@ -77,6 +84,13 @@ func Load() (*Config, error) {
|
||||
}
|
||||
cfg.UpdateTimeout = d
|
||||
}
|
||||
if v := os.Getenv("POLL_INTERVAL"); v != "" {
|
||||
d, err := time.ParseDuration(v)
|
||||
if err != nil || d <= 0 {
|
||||
return nil, fmt.Errorf("POLL_INTERVAL must be a positive duration such as 6h, got %q", v)
|
||||
}
|
||||
cfg.PollInterval = d
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user