feat(laya): integrate HTTP ranking service
Add the pinned Laya HTTP ranker and production composition, configure the CPU Compose service and cache, and document operations. Cover protocol validation, generation orchestration, sanitized logging, and Compose wiring. Refs #17 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
36
backend/internal/config/laya_test.go
Normal file
36
backend/internal/config/laya_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLayaEnvironment(t *testing.T) {
|
||||
t.Setenv("DATABASE_URL", "unused")
|
||||
t.Setenv("JWT_SECRET", "unused")
|
||||
t.Setenv("ENCRYPTION_KEY", strings.Repeat("ab", 32))
|
||||
t.Setenv("LAYA_URL", "")
|
||||
t.Setenv("LAYA_TIMEOUT", "")
|
||||
t.Setenv("LAYA_API_KEY", "")
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.LayaURL != "http://laya:8000" || cfg.LayaTimeout != 120*time.Second {
|
||||
t.Fatal("incorrect Laya defaults")
|
||||
}
|
||||
t.Setenv("LAYA_URL", "http://127.0.0.1:8001")
|
||||
t.Setenv("LAYA_TIMEOUT", "45s")
|
||||
t.Setenv("LAYA_API_KEY", "test-secret")
|
||||
cfg, err = Load()
|
||||
if err != nil || cfg.LayaURL != "http://127.0.0.1:8001" || cfg.LayaTimeout != 45*time.Second || cfg.LayaAPIKey != "test-secret" {
|
||||
t.Fatalf("environment not loaded: %v", err)
|
||||
}
|
||||
for _, value := range []string{"invalid", "0s", "-1s", "11m"} {
|
||||
t.Setenv("LAYA_TIMEOUT", value)
|
||||
if _, err := Load(); err == nil {
|
||||
t.Errorf("accepted timeout %s", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user