feat: infisical proxy#58
Conversation
- Added `proxy.go` to handle proxy server commands, including starting the server and printing cache debug information. - Introduced a caching mechanism in `cache.go` to store and manage HTTP responses, supporting token-based cache invalidation. - Implemented resync logic to refresh cached entries based on expiration. - Added command-line flags for configuring the proxy server's domain, listen address, resync interval, and cache TTL. - Included a debug endpoint for development mode to retrieve cache information.
- Removed the `startResyncLoop` function from `proxy.go` and moved it to a new `resync.go` file for better organization. - Enhanced the caching system in `cache.go` to include a compound path index for improved cache entry management and eviction after mutation calls. - Introduced a new method to handle resync responses, including rate limit handling and entry eviction based on HTTP status codes. - Updated the proxy server to utilize a streaming client for long-lived connections and improved logging for cache hits and misses. - Added functionality to purge cache entries based on mutation paths across all tokens.
- Updated the `compoundPathIndex` comment in `cache.go` to clarify its purpose for purging after mutation calls. - Changed the locking mechanism in `GetFirstRequestForToken` to use a write lock for thread safety. - Enhanced the `EvictAllEntriesForToken` and `RemoveTokenFromIndex` methods to delete entries from the `compoundPathIndex` when a token is evicted. - Improved response handling in `handleResyncResponse` by ensuring the response body is closed properly in all cases to prevent resource leaks.
Greptile SummaryIntroduced a new Key Changes:
Implementation Quality: Confidence Score: 5/5
Important Files Changed
|
…y server - Enhanced the `startProxyServer` function in `proxy.go` to log errors when parsing mutation request bodies fails, ensuring better visibility into potential cache issues.
|
@greptile re-review this PR with the responses to your previous comments in mind. Also update the summary and score you posted earlier |
|
@greptile re-review with the latest changes and comments in mind. update summary when done |
|
@greptile, once again, re-review the pr and update your summary with my previous comments in mind |
fangpenlin
left a comment
There was a problem hiding this comment.
half way through the testing. I think code looks mostly fine. Had a few suggestions. Found a bug tho, already DM you in slack. Will continue testing tomorrow
Description 📣
We are introducing the new proxy command to the CLI.
You can use it like this:
Here's a quick demonstration
Screenshare.-.2025-11-14.11_16_51.AM.mp4
And a more in-depth documentation can be found here: https://www.notion.so/infisical/Infisical-Proxy-2a9564692229808db6bdd30b73ed041a
Type ✨
Tests 🛠️
If you're running the CLI locally, you can use the debug command to get a snapshot of your in-memory cache:
go run main.go proxy debug --listen-address=localhost:8081Also, run the proxy start command with the
--log-level=debugflag for better observability in the tests.Tests:
access-token-check-intervalto1sand thestatic-secrets-refresh-intervalto1sListandRetrievesecret requestsapi/v1/events/subscribe/project-eventsTesting rate-limiting:
Remove this if statement in the
backend/src/server/app.tsfile: