8d1518b961
fix(tests): configurable retry delays and circuit backoff overflow
...
Three bugs fixed:
1. **Test suite timeout** — The main-package test suite timed out at 120s
because each failing request triggered 7 retries with exponential
backoff (500ms base → 10s max ≈ 25.5s per request). Tests that trip
the circuit breaker (3 requests × 25.5s = 76.5s) plus
TestStartHTTPProxy_ErrorHandlerConfigured (another 25.5s) pushed
cumulative time past the limit.
Fix: add `Client.RetryBaseDelayMs` / `Client.RetryMaxDelayMs` config
fields (env: CLIENT_RETRY_BASE_DELAY_MS / CLIENT_RETRY_MAX_DELAY_MS,
defaults 500ms / 10000ms). Tests override these to 10ms so retry
exhaustion completes in milliseconds. Full suite now runs in ~35s.
2. **effectiveCircuitBackoff float overflow** — On amd64, converting
`+Inf` (float64) to `time.Duration` (int64) saturates to MinInt64,
not MaxInt64. The existing "< base" guard then returned `base` instead
of `maxSaneCircuitBackoff`, breaking the sanity ceiling for an uncapped
config with a high trip count. Fix: detect `math.IsInf / math.IsNaN`
before the cast and return the ceiling directly.
3. **TestStartHTTPProxy_ErrorHandlerConfigured** — standalone top-level
test calling parseConfig() directly, bypassing the TestSuite override.
Now sets and restores RetryBaseDelayMs/RetryMaxDelayMs explicitly.
Co-authored-by: lukaszraczylo <[email protected] >
2026-08-14 15:58:10 +00:00
lukaszraczylo
044fa41744
fix(config): validate env values and clamp unsafe settings
...
Invalid numeric environment values parsed to zero, an invalid prefixed
value fell through to a stale unprefixed value, and the prefixed boolean
parser rejected on and yes that the unprefixed parser accepted. A
non-positive cache TTL or retry-budget rate could crash or disable a
subsystem.
Parsing now warns and uses the coded default for an invalid value,
prefixed and unprefixed booleans accept the same tokens, and the cache
TTL and retry rate are clamped. A dead per-endpoint circuit config was
removed and a BIND_ADDRESS option was added, defaulting to the current
all-interfaces bind. The pprof server now stops on shutdown.
2026-08-14 11:10:39 +01:00
lukaszraczylo
c2c75d69c0
perf+coverage: optimisation pass + coverage push to ≥70%
...
Performance / resource usage:
- circuit_breaker_metrics: fix data race on failCounters map (RWMutex + double-checked locking)
- server.go: drop user_id and op_name metric labels (Prometheus cardinality bound); de-duplicate extractUserInfo
- graphql.go: gate runtime.ReadMemStats per-request behind ENABLE_ALLOCATION_TRACKING flag (default off)
- graphql.go: collapse two-pass AST scan into single pass; lower-case once
- sanitization.go: cache compiled redaction regexes per pattern via sync.Map; hoist inner constants to pkg vars
- proxy.go: hoist connection/timeout substrings to pkg vars; sentinel errors for static error paths; drop dead Headers map alloc
- metrics_aggregator.go: log-field allocation guarded by Logger.IsLevelEnabled
- logging/logger.go: add IsLevelEnabled helper
- lru_cache.go: 16-shard sharding, FNV-1a routing (concurrent throughput +22%)
- cache/memory/lru_memory_cache.go: gzip compress/decompress moved outside mu.Lock
- rps_tracker.go: RWMutex+uint64 -> atomic.Uint64
- retry_budget.go: drop unused mutex
- api.go: bannedUsersIDs map+RWMutex -> sync.Map (+ snapshot/replace helpers)
- tracing/tracing.go: pkg-level constSpanAttrs, copy-then-append in StartSpanWithAttributes
- admin_dashboard.go: handleStatsWebSocket reuses bytes.Buffer + json.Encoder per connection
Build / runtime:
- Makefile: -ldflags="-s -w" -trimpath, CGO_ENABLED=0 for build (=1 for test recipes)
- Dockerfile + Dockerfile.goreleaser: ENV GOMEMLIMIT=512MiB
- main.go: blank import go.uber.org/automaxprocs (cgroup-aware GOMAXPROCS)
- main.go: PPROF_PORT env var wires net/http/pprof on 127.0.0.1 only with full server timeouts
- README.md: env-var docs + metric-label docs updated; cardinality note
Test coverage push (per package):
- main 51.2% -> 74.7%
- cache 66.3% -> 93.7%
- cache/redis 45.5% -> 98.2%
- tracing 66.7% -> 72.9%
- (cache/memory 91.6%, logging 91.9%, monitoring 77.6%, pkg/pools 100% unchanged)
New test files: coverage_micro_test, coverage_extras_test, server_handlers_test,
api_health_test, admin_dashboard_cluster_test, metrics_aggregator_test, concerns_test,
cache/cache_coverage_test, cache/redis/redis_coverage_test, tracing/tracing_coverage_test.
Bug fix: connection_resilience_test.go TestIntegratedHealthManagement.health_manager_startup
was sync.Once-coupled to InitializeBackendHealth and panicked when another test (e.g. via
parseConfig) had already triggered Once. Use NewBackendHealthManager directly.
2026-04-19 19:49:24 +01:00
lukaszraczylo
da8ec5f21d
Add LRU cache support.
2025-12-03 10:22:33 +00:00
lukaszraczylo
39dc7b49cf
Improve caching by adding user ids and roles to hash.
2025-11-22 17:02:16 +00:00
lukaszraczylo and GitHub
cedee416a8
improvements mid may 2025 ( #24 )
...
* General improvements and bug fixes.
* Improve tests coverage.
* fixup! Improve tests coverage.
* Update README.md with latest changes.
* Fix the uint32
* Resolve issue with race condition for logging.
* fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* Fix the test of the rate limiter
* Add default ratelimit.json file
* Update dependencies.
* Significant refactor.
* fixup! Significant refactor.
* fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! fixup! fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
* fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Merge remote-tracking branch 'origin/main' into improvements-mid-apr-2025
2025-09-30 18:27:33 +01:00
lukaszraczylo and GitHub
6af5aefe54
Add tracing and relevant tests ( #21 )
...
* Add tracing and relevant tests.
* fixup! Add tracing and relevant tests.
* gofmt the code 🤷
* fixup! gofmt the code 🤷
2025-01-08 18:29:25 +00:00
lukaszraczylo and GitHub
61d7a45d00
Update cache library, use miniredis for testing, add additional benchmarks. ( #14 )
...
Update cache library,
Update logging library,
use miniredis for testing, add additional benchmarks.
2024-06-19 23:10:36 +01:00
lukaszraczylo
e5b3eff1cd
Adjust field alignment.
2024-06-12 12:07:22 +01:00
lukaszraczylo
b2380c689b
Add cleanup of the event and invocation logs on timer.
2024-06-12 11:47:21 +01:00
lukaszraczylo
12e0294945
Add distibuted cache with Redis
2024-06-11 11:35:50 +01:00
lukaszraczylo and GitHub
e495cf23d9
Read only endpoint support ( #10 )
...
* This change introduces ability to set additional endpoint leading to the
instance of the graphql server connected to the read only database.
If regular query is detected and endpoint for `HOST_GRAPHQL_READONLY` value is set,
the query will be proxied to it. Mutations and non-graphql will be sent
to the `HOST_GRAPHQL` endpoint.
2024-03-12 11:16:35 +00:00
lukaszraczylo
b19b17b7c4
Realign the structs to decrease memory footprint.
...
Add the timeout settings to address the connection drops.
2023-12-14 17:16:38 +00:00
lukaszraczylo
105c624426
Add purging metrics on timer.
2023-11-17 13:47:54 +00:00
lukaszraczylo and GitHub
0b642f8be1
Add ability to reset metrics between crawl to limit payload absorbed ( #5 )
...
by the prometheus/victoria metric crawlers.
2023-11-16 16:45:48 +00:00
lukaszraczylo
3d70018179
Add configurable timeout for queries.
2023-10-24 10:40:17 +01:00
lukaszraczylo
35e6069f5e
Add the healtcheck checks on the end server.
2023-10-19 15:43:49 +01:00
lukaszraczylo and GitHub
92359c1114
Cleanup pt 1 ( #4 )
...
* Disable startup headers.
* Add banning / unbanning of specific user.
2023-10-19 14:36:16 +01:00
lukaszraczylo
2a0302ab75
Create allow list for event when intospection is blocked but developers
...
really want to use certain subqueries.
2023-10-15 10:01:23 +01:00
lukaszraczylo
dbd005bdcf
Remove external library dependency, use homebrewed cache instead.
2023-10-13 15:22:47 +01:00
lukaszraczylo
bf9ec2c877
Reuse fasthttp client
2023-10-12 21:16:57 +01:00
lukaszraczylo
815a6841ed
Add ability to set up allowed paths for proxying.
2023-10-12 14:12:03 +01:00
lukaszraczylo
1a3628837f
Extract helper libraries from private repo of telegram-bot.app
2023-10-10 22:16:50 +01:00
lukaszraczylo
51dfc8d9be
Add ability to look for the role in header.
2023-10-10 19:48:56 +01:00
lukaszraczylo
7de1cf7cc7
Add read only mode to block all the queries with mutations.
2023-10-10 19:26:36 +01:00
lukaszraczylo
ac44056a00
Add role ratelimit ( #1 )
...
* Add ratelimit configuration.
* Add rate limiting :party:
2023-10-09 17:46:50 +01:00
lukaszraczylo
743eed7f71
Add ability to enable / disable access log.
...
In high frequency environments it can be a little bit noisy.
2023-10-09 17:46:50 +01:00
lukaszraczylo
3ac7c115aa
Blocking introspection queries.
2023-10-08 18:07:24 +01:00
lukaszraczylo
8673f1caf8
Remove println and replace it with our logging
2023-10-07 14:13:29 +01:00
lukaszraczylo
39d3afdd05
Initial commit.
2023-10-07 11:14:20 +01:00