Prepare verified laboratory 7 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:32:06 +03:00
parent 20afc2c790
commit eb1b5c7b84
677 changed files with 208256 additions and 64 deletions
@@ -0,0 +1,24 @@
package lifecycle
import (
"backend/internal/adapter/freshness"
"os"
"strconv"
"time"
)
func FromEnvironment() (*freshness.Watcher, error) {
path := os.Getenv("SECRET_FRESHNESS_FILE")
if path == "" {
return nil, nil
}
age := 120
if s := os.Getenv("SECRET_MAX_AGE_SECONDS"); s != "" {
n, e := strconv.Atoi(s)
if e != nil || n < 1 || n > 3600 {
return nil, ErrConfiguration
}
age = n
}
return freshness.New(freshness.Ports{Read: freshness.FileReader(path), Now: time.Now, NewTicker: freshness.SystemTicker}, time.Duration(age)*time.Second, min(5*time.Second, time.Duration(age)*time.Second))
}