Files
sentinela-go/internal/config/config.go
Rainbow f7c8b446bf feat: Sentinela v0.2.0 — Brazilian Financial Data API in Go
- 20 Go source files, single 16MB binary
- SQLite + FTS5 full-text search (pure Go, no CGO)
- BCB integration: Selic, CDI, IPCA, USD/BRL, EUR/BRL
- CVM integration: 2,524 companies from registry
- Fiber v2 REST API with 42 handlers
- Auto-seeds on first run (~5s for BCB + CVM)
- Token bucket rate limiter, optional API key auth
- Periodic sync scheduler (configurable)
- Graceful shutdown, structured logging (slog)
- All endpoints tested with real data
2026-02-10 11:15:54 -03:00

49 lines
851 B
Go

package config
import (
"os"
"strconv"
)
type Config struct {
Port int
DatabasePath string
RateLimit int
APIKey string
SyncInterval string
LogLevel string
}
func Load() *Config {
c := &Config{
Port: 3333,
DatabasePath: "data/sentinela.db",
RateLimit: 100,
SyncInterval: "30m",
LogLevel: "info",
}
if v := os.Getenv("PORT"); v != "" {
if n, err := strconv.Atoi(v); err == nil {
c.Port = n
}
}
if v := os.Getenv("DATABASE_PATH"); v != "" {
c.DatabasePath = v
}
if v := os.Getenv("RATE_LIMIT"); v != "" {
if n, err := strconv.Atoi(v); err == nil {
c.RateLimit = n
}
}
if v := os.Getenv("API_KEY"); v != "" {
c.APIKey = v
}
if v := os.Getenv("SYNC_INTERVAL"); v != "" {
c.SyncInterval = v
}
if v := os.Getenv("LOG_LEVEL"); v != "" {
c.LogLevel = v
}
return c
}