mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-20 06:28:13 +00:00
feat(deps)!: migrate from fiber v2 to fiber v3
BREAKING CHANGE: upgrades the HTTP framework from gofiber/fiber/v2 to gofiber/fiber/v3, and gofiber/websocket/v2 to gofiber/contrib/v3/websocket. - Handlers now take fiber.Ctx (interface) instead of *fiber.Ctx. - DisableStartupMessage moved from fiber.Config to fiber.ListenConfig on the proxy/api/monitoring Listen calls. - cors AllowOrigins is now []string; c.BodyParser -> c.Bind().Body(). - app.Test takes fiber.TestConfig instead of an int timeout (tests updated). - WebSocket swapped to contrib/v3/websocket (same Conn/New/Config/IsCloseError/IsWebSocketUpgrade API; Conn.Query preserved). - Adopts fasthttp v1.71.0 (pulled by fiber v3), resolving the v1.71 Host-header enforcement that broke the prior pinned-v1.69 workaround. fix(connpool): the background keep-alive goroutine no longer reads the mutable global cfg (captures HostGraphQL/HealthcheckGraphQL at pool creation). Under v3 timing it raced with parseConfig/test cfg reassignment; go test -race ./... is now clean (0 data races). test: make the circuit-breaker cache-fallback and request-coalescing integration tests deterministic (cache TTL outlives the retry loop; coalescing asserts against a measured single-request baseline instead of a hard-coded count); drop the flaky timing-ratio assertion in TestTimingAttackResistance (constant-time guarantee comes from subtle.ConstantTimeCompare, not wall-clock timing). Verified: go build, go vet, golangci-lint (0 issues), go test -race ./... (all packages pass, 0 races), govulncheck (no vulnerabilities). App + dashboard + WebSocket verified live under v3 in single-node and cluster modes.
This commit is contained in:
+16
-4
@@ -18,6 +18,8 @@ type ConnectionPoolManager struct {
|
||||
client *fasthttp.Client
|
||||
cancel context.CancelFunc
|
||||
logger *libpack_logging.Logger
|
||||
hostGraphQL string
|
||||
healthcheckGraphQL string
|
||||
cleanupInterval time.Duration
|
||||
keepAliveInterval time.Duration
|
||||
recoveryCheckInterval time.Duration
|
||||
@@ -45,6 +47,14 @@ func NewConnectionPoolManager(client *fasthttp.Client) *ConnectionPoolManager {
|
||||
cpm.logger = cfg.Logger
|
||||
}
|
||||
|
||||
// Capture backend URLs at creation. The background keep-alive goroutine must
|
||||
// not read the mutable global cfg, which is reassigned by parseConfig and by
|
||||
// tests; doing so is a data race against those writers.
|
||||
if cfg != nil {
|
||||
cpm.hostGraphQL = cfg.Server.HostGraphQL
|
||||
cpm.healthcheckGraphQL = cfg.Server.HealthcheckGraphQL
|
||||
}
|
||||
|
||||
// Start periodic maintenance tasks
|
||||
cpm.startPeriodicMaintenance()
|
||||
|
||||
@@ -133,8 +143,10 @@ func (cpm *ConnectionPoolManager) performKeepAlive() {
|
||||
return
|
||||
}
|
||||
|
||||
// Only perform keep-alive if we have a backend URL configured
|
||||
if cfg == nil || cfg.Server.HostGraphQL == "" {
|
||||
// Only perform keep-alive if we have a backend URL configured.
|
||||
// Uses the URL captured at creation (cpm.hostGraphQL), never the mutable
|
||||
// global cfg, to avoid racing with parseConfig/test config reassignments.
|
||||
if cpm.hostGraphQL == "" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -152,10 +164,10 @@ func (cpm *ConnectionPoolManager) performKeepAlive() {
|
||||
defer fasthttp.ReleaseResponse(resp)
|
||||
|
||||
// Try to use health check endpoint if available, otherwise use base URL
|
||||
healthURL := cfg.Server.HealthcheckGraphQL
|
||||
healthURL := cpm.healthcheckGraphQL
|
||||
if healthURL == "" {
|
||||
// Use base URL with proper path separator
|
||||
baseURL := cfg.Server.HostGraphQL
|
||||
baseURL := cpm.hostGraphQL
|
||||
if !strings.HasSuffix(baseURL, "/") {
|
||||
baseURL += "/"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user