You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/09/10 15:39:08 UTC
[GitHub] [superset] villebro commented on a change in pull request #16618: feat: feature flag configurable custom backend
villebro commented on a change in pull request #16618:
URL: https://github.com/apache/superset/pull/16618#discussion_r706280559
##########
File path: superset/utils/feature_flag_manager.py
##########
@@ -24,24 +24,36 @@ class FeatureFlagManager:
def __init__(self) -> None:
super().__init__()
self._get_feature_flags_func = None
+ self._is_feature_enabled_func = None
self._feature_flags: Dict[str, Any] = {}
def init_app(self, app: Flask) -> None:
self._get_feature_flags_func = app.config["GET_FEATURE_FLAGS_FUNC"]
+ self._is_feature_enabled_func = app.config["IS_FEATURE_ENABLED_FUNC"]
self._feature_flags = app.config["DEFAULT_FEATURE_FLAGS"]
self._feature_flags.update(app.config["FEATURE_FLAGS"])
def get_feature_flags(self) -> Dict[str, Any]:
if self._get_feature_flags_func:
return self._get_feature_flags_func(deepcopy(self._feature_flags))
-
+ if self._is_feature_enabled_func:
Review comment:
Totally optional, but this makes it slightly more explicit/resilient:
```suggestion
if callable(self._is_feature_enabled_func):
```
##########
File path: superset/config.py
##########
@@ -427,7 +427,14 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
# feature_flags_dict['some_feature'] = g.user and g.user.get_id() == 5
# return feature_flags_dict
GET_FEATURE_FLAGS_FUNC: Optional[Callable[[Dict[str, bool]], Dict[str, bool]]] = None
-
+# A function that receives a feature flag name and a optional default value.
Review comment:
nit
```suggestion
# A function that receives a feature flag name and an optional default value.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org