ajoute snapshot

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-06-13 22:52:13 +02:00
commit 0f2d7126eb
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
11 changed files with 862 additions and 19 deletions

View file

@ -2,17 +2,19 @@ package config
import (
"os"
"strconv"
"time"
)
type Config struct {
DatabaseURL string
Port string
Env string
OpenFIGIKey string
CoinGeckoKey string
PriceFetchInterval time.Duration
PriceCleanInterval time.Duration
DatabaseURL string
Port string
Env string
OpenFIGIKey string
CoinGeckoKey string
PriceFetchInterval time.Duration
PriceCleanInterval time.Duration
SnapshotHorizonDays int // nombre de jours dans le futur couverts par les snapshots
}
func Load() *Config {
@ -21,14 +23,20 @@ func Load() *Config {
fetchInterval = time.Hour
}
horizonDays, err := strconv.Atoi(getenv("SNAPSHOT_HORIZON_DAYS", "30"))
if err != nil || horizonDays < 0 {
horizonDays = 30
}
return &Config{
DatabaseURL: getenv("DATABASE_URL", "postgres://account:account@localhost:5432/account?sslmode=disable"),
Port: getenv("PORT", "8080"),
Env: getenv("ENV", "development"),
OpenFIGIKey: os.Getenv("OPENFIGI_API_KEY"),
CoinGeckoKey: os.Getenv("COINGECKO_API_KEY"),
PriceFetchInterval: fetchInterval,
PriceCleanInterval: 24 * time.Hour,
DatabaseURL: getenv("DATABASE_URL", "postgres://account:account@localhost:5432/account?sslmode=disable"),
Port: getenv("PORT", "8080"),
Env: getenv("ENV", "development"),
OpenFIGIKey: os.Getenv("OPENFIGI_API_KEY"),
CoinGeckoKey: os.Getenv("COINGECKO_API_KEY"),
PriceFetchInterval: fetchInterval,
PriceCleanInterval: 24 * time.Hour,
SnapshotHorizonDays: horizonDays,
}
}