You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 23017e0
Browse filesBrowse the repository at this point in the historyBrowse files
perf(feature_flags): validate schema once per fetched document (#8431)
* perf(feature_flags): validate schema once per fetched document
FeatureFlags.get_configuration built a SchemaValidator and walked the
whole document on every call. evaluate and get_enabled_features both call
it, so a handler evaluating five flags validated the full document five
times per invocation, even when the store served it from cache.
Skip validation when the store returns the same dict object that was
last validated. The Parameters cache hands back the same object until
expiry, so identity is a reliable signal for a cache hit, and a fresh
document is always validated. A strong reference to the last validated
document is kept so its id() cannot be recycled.
AppConfigStore with an envelope produced a new object per call from the
JMESPath query, which would defeat the check. Memoise the extraction on
the raw document's identity so envelope users benefit as well.
Closes#8426
* docs(feature_flags): document configuration immutability
---------
Co-authored-by: Leandro <lcdama@amazon.pt>
Copy file name to clipboardExpand all lines: docs/utilities/feature_flags.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -369,6 +369,9 @@ You can override `max_age` parameter when instantiating the store.
369
369
370
370
You can access the configuration fetched from the store via `get_raw_configuration` property within the store instance.
371
371
372
+
???+ warning
373
+
Treat the returned configuration as read-only. If you need to modify it, create a deep copy first.
374
+
372
375
=== "getting_stored_features.py"
373
376
374
377
```python hl_lines="9"
@@ -555,6 +558,10 @@ You can create your own custom FeatureFlags store provider by inheriting the `St
555
558
***`get_raw_configuration()`** – get the raw configuration from the store provider and return the parsed JSON dictionary
556
559
***`get_configuration()`** – get the configuration from the store provider, parsing it as a JSON dictionary. If an envelope is set, extract the envelope data
557
560
561
+
Feature Flags can reuse a previously validated configuration when a store returns the same dictionary. Custom store
562
+
providers must return a new dictionary when the configuration changes instead of modifying a previously returned
563
+
dictionary in place.
564
+
558
565
Here are an example of implementing a custom store provider using Amazon S3, a popular object storage.
0 commit comments