perf(cap): add runtime settings snapshot for dynamic config

Replace per-request GetByKey calls with a singleflight-backed
RuntimeSettings snapshot loaded via ListSystemConfigsByKeys.
Invalidate snapshot on admin cap_* writes and via Redis pub/sub.
Simplify VerifyMiddleware and update PERFORMANCE.md status.
This commit is contained in:
ryan
2026-06-17 12:07:02 +08:00
parent d3ba767087
commit 9550fa6ff3
14 changed files with 634 additions and 322 deletions
+3 -3
View File
@@ -9,7 +9,6 @@ import (
"net/http/httptest"
"testing"
"github.com/Rain-kl/Wavelet/internal/db"
"github.com/Rain-kl/Wavelet/internal/model"
"github.com/Rain-kl/Wavelet/internal/testhelper"
"github.com/gin-gonic/gin"
@@ -21,9 +20,10 @@ func TestCORSMiddleware(t *testing.T) {
gin.SetMode(gin.TestMode)
// Helper to clear config cache
clearConfigCache := func() {
_ = db.Redis.Del(context.Background(), db.PrefixedKey(model.SystemConfigRedisHashKey)).Err()
if err := model.InvalidateAllSystemConfigCaches(context.Background()); err != nil {
t.Fatalf("InvalidateAllSystemConfigCaches() error = %v", err)
}
}
t.Run("missing server_address configuration returns no CORS headers", func(t *testing.T) {