Skip to content

Commit 4d397a7

Browse files
committed
refactor: rename ConfigurationStore, SchemaFetcher
1 parent b274eed commit 4d397a7

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""Advanced feature toggles utility
22
"""
3-
from .appconfig_fetcher import AppConfigFetcher
4-
from .configuration_store import ConfigurationStore
3+
from .appconfig import AppConfigStore
4+
from .base import StoreProvider
55
from .exceptions import ConfigurationError
6+
from .feature_flags import FeatureFlags
67
from .schema import ACTION, SchemaValidator
7-
from .schema_fetcher import SchemaFetcher
88

99
__all__ = [
1010
"ConfigurationError",
11-
"ConfigurationStore",
11+
"FeatureFlags",
1212
"ACTION",
1313
"SchemaValidator",
14-
"AppConfigFetcher",
15-
"SchemaFetcher",
14+
"AppConfigStore",
15+
"StoreProvider",
1616
]

aws_lambda_powertools/utilities/feature_toggles/appconfig_fetcher.py renamed to aws_lambda_powertools/utilities/feature_toggles/appconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
from aws_lambda_powertools.utilities.parameters import AppConfigProvider, GetParameterError, TransformParameterError
77

8+
from .base import StoreProvider
89
from .exceptions import ConfigurationError
9-
from .schema_fetcher import SchemaFetcher
1010

1111
logger = logging.getLogger(__name__)
1212

1313

1414
TRANSFORM_TYPE = "json"
1515

1616

17-
class AppConfigFetcher(SchemaFetcher):
17+
class AppConfigStore(StoreProvider):
1818
def __init__(
1919
self,
2020
environment: str,

aws_lambda_powertools/utilities/feature_toggles/schema_fetcher.py renamed to aws_lambda_powertools/utilities/feature_toggles/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Any, Dict
33

44

5-
class SchemaFetcher(ABC):
5+
class StoreProvider(ABC):
66
def __init__(self, configuration_name: str, cache_seconds: int):
77
self.name = configuration_name
88
self._cache_seconds = cache_seconds

aws_lambda_powertools/utilities/feature_toggles/configuration_store.py renamed to aws_lambda_powertools/utilities/feature_toggles/feature_flags.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
from typing import Any, Dict, List, Optional, cast
33

44
from . import schema
5+
from .base import StoreProvider
56
from .exceptions import ConfigurationError
6-
from .schema_fetcher import SchemaFetcher
77

88
logger = logging.getLogger(__name__)
99

1010

11-
class ConfigurationStore:
12-
def __init__(self, schema_fetcher: SchemaFetcher):
11+
class FeatureFlags:
12+
def __init__(self, schema_fetcher: StoreProvider):
1313
"""constructor
1414
1515
Parameters
1616
----------
17-
schema_fetcher: SchemaFetcher
17+
schema_fetcher: StoreProvider
1818
A schema JSON fetcher, can be AWS AppConfig, Hashicorp Consul etc.
1919
"""
2020
self._logger = logger

docs/utilities/feature_flags.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ By default, this utility provides AWS AppConfig as a configuration store. As suc
6161
Potential changes to be validated when docs are in a better shape
6262

6363
- [x] ~~`rules_context` to `context`~~
64-
- [ ] `ConfigurationStore` to `FeatureFlags`
65-
- [ ] `SchemaFetcher` to `StoreProvider`
64+
- [x] `ConfigurationStore` to `FeatureFlags`
65+
- [x] `StoreProvider` to `StoreProvider`
6666
- [ ] Use `base.py` for interfaces for consistency (e.g. Metrics, Tracer, etc.)
67-
- [ ] Some docstrings and logger refer to AWS AppConfig only (outdated given SchemaFetcher)
67+
- [ ] Some docstrings and logger refer to AWS AppConfig only (outdated given StoreProvider)
6868
- [ ] Review why we're testing a private method(`is_rule_matched`)
6969
- [x] AppConfig construct parameter names for consistency (e.g. `configuration_name` -> `name`, `service` -> `application`)
7070
- [ ] Review `get_configuration`, `get_json_configuration`

tests/functional/feature_toggles/test_feature_toggles.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from botocore.config import Config
55

66
from aws_lambda_powertools.utilities.feature_toggles import ConfigurationError, schema
7-
from aws_lambda_powertools.utilities.feature_toggles.appconfig_fetcher import AppConfigFetcher
8-
from aws_lambda_powertools.utilities.feature_toggles.configuration_store import ConfigurationStore
7+
from aws_lambda_powertools.utilities.feature_toggles.appconfig import AppConfigStore
8+
from aws_lambda_powertools.utilities.feature_toggles.feature_flags import FeatureFlags
99
from aws_lambda_powertools.utilities.feature_toggles.schema import ACTION
1010
from aws_lambda_powertools.utilities.parameters import GetParameterError
1111

@@ -15,25 +15,25 @@ def config():
1515
return Config(region_name="us-east-1")
1616

1717

18-
def init_configuration_store(mocker, mock_schema: Dict, config: Config) -> ConfigurationStore:
18+
def init_configuration_store(mocker, mock_schema: Dict, config: Config) -> FeatureFlags:
1919
mocked_get_conf = mocker.patch("aws_lambda_powertools.utilities.parameters.AppConfigProvider.get")
2020
mocked_get_conf.return_value = mock_schema
2121

22-
app_conf_fetcher = AppConfigFetcher(
22+
app_conf_fetcher = AppConfigStore(
2323
environment="test_env",
2424
application="test_app",
2525
name="test_conf_name",
2626
cache_seconds=600,
2727
config=config,
2828
)
29-
conf_store: ConfigurationStore = ConfigurationStore(schema_fetcher=app_conf_fetcher)
29+
conf_store: FeatureFlags = FeatureFlags(schema_fetcher=app_conf_fetcher)
3030
return conf_store
3131

3232

33-
def init_fetcher_side_effect(mocker, config: Config, side_effect) -> AppConfigFetcher:
33+
def init_fetcher_side_effect(mocker, config: Config, side_effect) -> AppConfigStore:
3434
mocked_get_conf = mocker.patch("aws_lambda_powertools.utilities.parameters.AppConfigProvider.get")
3535
mocked_get_conf.side_effect = side_effect
36-
return AppConfigFetcher(
36+
return AppConfigStore(
3737
environment="env",
3838
application="application",
3939
name="conf",
@@ -423,7 +423,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
423423
def test_get_feature_toggle_handles_error(mocker, config):
424424
# GIVEN a schema fetch that raises a ConfigurationError
425425
schema_fetcher = init_fetcher_side_effect(mocker, config, GetParameterError())
426-
conf_store = ConfigurationStore(schema_fetcher)
426+
conf_store = FeatureFlags(schema_fetcher)
427427

428428
# WHEN calling get_feature_toggle
429429
toggle = conf_store.get_feature_toggle(feature_name="Foo", value_if_missing=False)
@@ -435,7 +435,7 @@ def test_get_feature_toggle_handles_error(mocker, config):
435435
def test_get_all_enabled_feature_toggles_handles_error(mocker, config):
436436
# GIVEN a schema fetch that raises a ConfigurationError
437437
schema_fetcher = init_fetcher_side_effect(mocker, config, GetParameterError())
438-
conf_store = ConfigurationStore(schema_fetcher)
438+
conf_store = FeatureFlags(schema_fetcher)
439439

440440
# WHEN calling get_all_enabled_feature_toggles
441441
toggles = conf_store.get_all_enabled_feature_toggles(context=None)

0 commit comments

Comments
 (0)