From 9131dd9278dcab9904be62570debd717daa410a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Fri, 23 Oct 2026 08:12:30 +0300 Subject: [PATCH] feat(config):lab4 add reconciler settings - RECONCILER_ENABLED (default true) - RECONCILER_INTERVAL_SECONDS (default 300 = 5 min) - RECONCILER_GRACE_SECONDS (default 3600 = 1 hour) Grace period ensures fresh uploads (< 1h pending) are not touched. --- backend/internal/config/config.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index d0cd0ee..6419db3 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -27,6 +27,10 @@ type Config struct { MaxUploadBytes int64 MaxImagePixels int64 + + ReconcilerEnabled bool + ReconcilerInterval time.Duration + ReconcilerGracePeriod time.Duration } func Load() (*Config, error) { @@ -104,6 +108,25 @@ func Load() (*Config, error) { return nil, fmt.Errorf("MAX_IMAGE_PIXELS должен быть положительным") } + reconcilerEnabled, err := readBool("RECONCILER_ENABLED", true) + if err != nil { + return nil, fmt.Errorf("RECONCILER_ENABLED: %w", err) + } + reconcilerIntervalSec, err := readInt("RECONCILER_INTERVAL_SECONDS", 300) + if err != nil { + return nil, fmt.Errorf("RECONCILER_INTERVAL_SECONDS: %w", err) + } + if reconcilerIntervalSec <= 0 { + return nil, fmt.Errorf("RECONCILER_INTERVAL_SECONDS должен быть положительным") + } + reconcilerGraceSec, err := readInt("RECONCILER_GRACE_SECONDS", 3600) + if err != nil { + return nil, fmt.Errorf("RECONCILER_GRACE_SECONDS: %w", err) + } + if reconcilerGraceSec <= 0 { + return nil, fmt.Errorf("RECONCILER_GRACE_SECONDS должен быть положительным") + } + return &Config{ Host: getenv("APP_HOST", "0.0.0.0"), Port: getenv("APP_PORT", "8080"), @@ -123,6 +146,10 @@ func Load() (*Config, error) { MaxUploadBytes: maxUploadBytes, MaxImagePixels: maxImagePixels, + + ReconcilerEnabled: reconcilerEnabled, + ReconcilerInterval: time.Duration(reconcilerIntervalSec) * time.Second, + ReconcilerGracePeriod: time.Duration(reconcilerGraceSec) * time.Second, }, nil }