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 and implements a throttling mechanism for remote API feature checks in the Switcher client, along with related configuration options and tests. The throttling feature caches recent results to avoid excessive API calls within a configurable period and adds support for background refresh using worker threads. Additionally, a utility method for serializing result details is added, and relevant documentation and tests are updated.
Throttling Feature Implementation:
Added a throttling mechanism to cache and reuse recent API check results within a specified period, reducing redundant remote calls. Throttling is enabled via the new
throttle(period)method onSwitcher, and background refresh is managed with a thread pool executor. (switcher_client/switcher.py[1] [2] [3] [4] [5];switcher_client/switcher_data.py[6] [7]Introduced the
throttle_max_workersoption inContextOptionsto control the maximum number of worker threads for background refresh tasks. (switcher_client/lib/globals/global_context.py[1];README.md[2] [3]API and Utility Enhancements:
to_dict()method to theResultDetailclass for easier serialization of result details, improving integration with logging and test output. (switcher_client/lib/types.pyswitcher_client/lib/types.pyR21-R27)Documentation Updates:
README.mdto document the new throttling feature and configuration options, including usage examples and parameter descriptions. (README.md[1] [2] [3]Testing Improvements:
tests/test_switcher_throttle.py[1] [2] [3] [4];tests/playground/index.py[5];tests/playground/util.py[6];tests/test_switcher_remote.py[7]Minor Refactoring:
buildtarget from theMakefile. (Makefile[1] [2];switcher_client/lib/utils/__init__.py[3]