feat: forward optional FastAPI control token
This commit is contained in:
1 parent
4b9c2da9f7
commit
a88bfad1d4
5 files changed
+70
-23
No files matched your search
+18
-15
@@ -9,28 +9,31 @@ import (
|
||||
|
||||
// Config is the process configuration.
|
||||
type Config struct {
|
||||
Addr string
|
||||
DataDir string
|
||||
FastAPIURL string
|
||||
ControlUser string
|
||||
ControlPass string
|
||||
Heartbeat time.Duration
|
||||
MLTimeout time.Duration
|
||||
Addr string
|
||||
DataDir string
|
||||
FastAPIURL string
|
||||
ControlUser string
|
||||
ControlPass string
|
||||
ControlToken string
|
||||
Heartbeat time.Duration
|
||||
MLTimeout time.Duration
|
||||
}
|
||||
|
||||
// Load reads configuration from env with local-development defaults.
|
||||
// CONTROL_USER / CONTROL_PASS have no defaults: POST /api/scenario fails
|
||||
// closed when they are unset.
|
||||
// closed when they are unset. CONTROL_TOKEN is optional and, when set, is
|
||||
// forwarded to FastAPI's internal /train endpoints as a Bearer token.
|
||||
func Load() Config {
|
||||
port := getenv("PORT", "8080")
|
||||
return Config{
|
||||
Addr: ":" + port,
|
||||
DataDir: getenv("DATA_DIR", "testdata/data"),
|
||||
FastAPIURL: getenv("FASTAPI_URL", "http://localhost:8000"),
|
||||
ControlUser: os.Getenv("CONTROL_USER"),
|
||||
ControlPass: os.Getenv("CONTROL_PASS"),
|
||||
Heartbeat: durationEnv("SSE_HEARTBEAT", 15*time.Second),
|
||||
MLTimeout: durationEnv("ML_TIMEOUT", 1500*time.Millisecond),
|
||||
Addr: ":" + port,
|
||||
DataDir: getenv("DATA_DIR", "testdata/data"),
|
||||
FastAPIURL: getenv("FASTAPI_URL", "http://localhost:8000"),
|
||||
ControlUser: os.Getenv("CONTROL_USER"),
|
||||
ControlPass: os.Getenv("CONTROL_PASS"),
|
||||
ControlToken: os.Getenv("CONTROL_TOKEN"),
|
||||
Heartbeat: durationEnv("SSE_HEARTBEAT", 15*time.Second),
|
||||
MLTimeout: durationEnv("ML_TIMEOUT", 1500*time.Millisecond),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user