Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request introduces a new throttling mechanism with Stale-While-Revalidate (SWR) behavior for feature flag evaluations, adds an execution logger for caching and retrieving evaluation results, and exposes new methods to interact with cached executions. These enhancements are designed to improve performance and observability, especially under high-traffic scenarios, and are accompanied by comprehensive documentation and tests.
Throttling and Caching Enhancements:
Throttlemethod to theSwitcherstruct, enabling SWR caching for feature flag evaluations. When throttling is enabled, cached results are returned immediately while a background refresh updates the cache, reducing latency and API load. The cache respects theFreezeoption and can be cleared viaClearLogger. (switcher.go,client.go,README.md) [1] [2] [3] [4]throttleTokensmechanism andrunBackgroundTaskinClientto limit concurrent background refreshes, configurable via context options. (client.go) [1] [2] [3] [4]Execution Logging and API:
executionLoggerfor storing and retrieving cached execution results, including input criteria and metadata (e.g., whether a result was cached). Exposed new API methods:GetExecution(to retrieve cached results) andClearLogger(to clear the cache), both as client methods and package-level functions. (execution_logger.go,client.go) [1] [2]switcher.go)Documentation and Testing:
README.md)execution_logger_test.go)Concurrency and Safety Improvements:
Switcherto ensure thread-safe access to mutable fields, especially for throttling and input criteria management. (switcher.go) [1] [2]switcher.go)Other Minor Updates:
README.md)These changes collectively improve the SDK's efficiency, scalability, and usability for high-throughput applications.