Commit Graph

38 Commits

Author SHA1 Message Date
lukaszraczylo b1045b8bc2 Retry budget. 2025-11-29 15:36:17 +00:00
lukaszraczylo 6a69694ab3 November improvements. (#29)
* Tackling the CPU / memory spikes after some time.

* Update admin dashboard, fix the circuit breaker and request coalescing.
2025-11-29 14:21:09 +00:00
lukaszraczylo 39dc7b49cf Improve caching by adding user ids and roles to hash. 2025-11-22 17:02:16 +00:00
lukaszraczylo 0fc776228f improvements mid apr 2025 (#26)
* General improvements and bug fixes.
* Admin dashboard
2025-10-01 00:20:45 +01:00
lukaszraczylo 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 98a5234ff6 fixup! Gofmt the codebase. 2025-02-26 01:03:44 +00:00
lukaszraczylo 1b7890f322 Gofmt the codebase. 2025-02-26 00:47:41 +00:00
lukaszraczylo 2ab78d35ce Configuration Management:
Optimized the getDetailsFromEnv function to reduce redundant lookups and improve type handling
Added direct environment variable access for better performance

Memory Cache Optimization:

Implemented a size-based compression threshold (1KB) to avoid compressing small payloads
Added cache size limits (10,000 entries) to prevent memory leaks
Implemented efficient eviction strategies for the oldest entries
Added atomic counter for thread-safe cache size tracking
Improved cleanup routines with GC triggering for large caches

Proxy Implementation:

Refactored the proxy code into smaller, focused functions for better maintainability
Optimized gzip handling for better performance
Improved error handling and logging
Enhanced tracing integration

GraphQL Processing:

Optimized introspection query checking with fast-path returns
Improved object pool usage
Added detailed comments for better code understanding
Split complex functions into smaller, more focused ones
Fixed test compatibility issues with introspection checking

Request Processing:

Refactored the request processing logic into smaller, focused functions
Separated user extraction, caching, and request handling for better maintainability
Improved error handling and response generation

Tracing Enhancements:

Added better span context management
Implemented custom attributes for more detailed tracing
Added sampling configuration to reduce overhead
Improved resource attribution with host and process information
Added timeout handling for tracing operations

Application Lifecycle:

Implemented graceful shutdown with proper signal handling
Added goroutine management with wait groups
Improved startup sequence with better error handling
Added timeout handling for shutdown operations
2025-02-25 23:34:39 +00:00
lukaszraczylo 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
Thomas P. 8bd2bdfd9c fix(proxy): handle lowercase Location header (#20)
When the upstream server returns a redirect HTTP response code but its "Location" header is in lowercase, the proxy will retry the request 5 times and eventually fail with an "missing Location header for http redirect" error.

Since the HTTP spec says header names are case-insensitive, we should handle this case properly. Adjust fasthttp options accordingly

Ref: https://github.com/valyala/fasthttp/issues/1361
2024-12-19 18:49:24 +00:00
lukaszraczylo 6b31e5c4c0 Little code cleanup. (#19) 2024-10-10 10:34:23 +01:00
lukaszraczylo cdd2a2a2c6 Enhance the retry logic for the proxied queries. 2024-08-20 12:45:22 +01:00
lukaszraczylo 9150b25227 Fixing the proxy timeout settings which were not passed to the client and and graphql server. 2024-08-20 11:38:40 +01:00
lukaszraczylo a24e6c8c4d fixup! Fix the introduced bug where RO endpoint could've been accidentally used. (#17) 2024-06-29 08:52:41 +01:00
lukaszraczylo b10a28bf52 General code optimisations. (#16)
* General code optimisations.
2024-06-28 12:31:01 +01:00
lukaszraczylo 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 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 3a18e0e935 Improve stats gathering and tests improvements. (#8) 2024-03-05 22:40:06 +00:00
lukaszraczylo 88ef1aac7f Reuse http client and add retry to the proxied requests. 2024-03-05 14:38:03 +00:00
lukaszraczylo 6d32278851 Reuse http client. 2024-03-05 14:24:49 +00:00
lukaszraczylo d3a8da1dcf Move location of the global proxy client from the per-req to main.
There's no need to re-create it every single time.
2024-02-05 14:35:33 +00:00
lukaszraczylo cd9c650226 Remove compression from proxied request. 2023-12-13 23:13:34 +00:00
lukaszraczylo d09940ebc4 Update connection settings. 2023-12-13 22:50:41 +00:00
lukaszraczylo b497ad1d1c Add generation of query uuid logs and easier debugging. 2023-10-25 14:11:44 +01:00
lukaszraczylo 3e6fa2036e Remove idle connections setup and allow the client to handle them 2023-10-24 16:56:01 +01:00
lukaszraczylo 4640eb2596 Adjust the timeout settings to prevent forever-hanging connections. 2023-10-24 15:52:40 +01:00
lukaszraczylo 3d70018179 Add configurable timeout for queries. 2023-10-24 10:40:17 +01:00
lukaszraczylo 2be4f17ea3 Disable header normalisation.
It looks like a bug in hasura which makes headers case sensitive.
2023-10-16 15:47:48 +01:00
lukaszraczylo 3cb9088b73 Revert disable headers normalising. 2023-10-16 15:31:45 +01:00
lukaszraczylo f50f98b3d6 Add printing out the request headers in debug mode. 2023-10-16 15:31:16 +01:00
lukaszraczylo bf18f36e45 If proxying of the query fails - return 500. 2023-10-13 14:48:53 +01:00
lukaszraczylo 3c0f9f49fd Add debugging option for the request / response cycle. 2023-10-13 14:23:05 +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 f41b2ae46f New: Proxy all the requests to the graphql server 2023-10-11 11:26:55 +01:00
lukaszraczylo 1a3628837f Extract helper libraries from private repo of telegram-bot.app 2023-10-10 22:16:50 +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