Skip to content

Commit b274eed

Browse files
committed
refactor: AppConfig params to match Parameters
1 parent 619c547 commit b274eed

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

aws_lambda_powertools/utilities/feature_toggles/appconfig_fetcher.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class AppConfigFetcher(SchemaFetcher):
1818
def __init__(
1919
self,
2020
environment: str,
21-
service: str,
22-
configuration_name: str,
21+
application: str,
22+
name: str,
2323
cache_seconds: int,
2424
config: Optional[Config] = None,
2525
):
@@ -28,19 +28,19 @@ def __init__(
2828
Parameters
2929
----------
3030
environment: str
31-
what appconfig environment to use 'dev/test' etc.
32-
service: str
33-
what service name to use from the supplied environment
34-
configuration_name: str
35-
what configuration to take from the environment & service combination
31+
Appconfig environment, e.g. 'dev/test' etc.
32+
application: str
33+
AppConfig application name, e.g. 'powertools'
34+
name: str
35+
AppConfig configuration name e.g. `my_conf`
3636
cache_seconds: int
3737
cache expiration time, how often to call AppConfig to fetch latest configuration
3838
config: Optional[Config]
3939
boto3 client configuration
4040
"""
41-
super().__init__(configuration_name, cache_seconds)
41+
super().__init__(name, cache_seconds)
4242
self._logger = logger
43-
self._conf_store = AppConfigProvider(environment=environment, application=service, config=config)
43+
self._conf_store = AppConfigProvider(environment=environment, application=application, config=config)
4444

4545
def get_json_configuration(self) -> Dict[str, Any]:
4646
"""Get configuration string from AWs AppConfig and return the parsed JSON dictionary
@@ -60,7 +60,7 @@ def get_json_configuration(self) -> Dict[str, Any]:
6060
return cast(
6161
dict,
6262
self._conf_store.get(
63-
name=self.configuration_name,
63+
name=self.name,
6464
transform=TRANSFORM_TYPE,
6565
max_age=self._cache_seconds,
6666
),

aws_lambda_powertools/utilities/feature_toggles/schema_fetcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
class SchemaFetcher(ABC):
66
def __init__(self, configuration_name: str, cache_seconds: int):
7-
self.configuration_name = configuration_name
7+
self.name = configuration_name
88
self._cache_seconds = cache_seconds
99

1010
@abstractmethod
1111
def get_json_configuration(self) -> Dict[str, Any]:
12-
"""Get configuration string from any configuration storing service and return the parsed JSON dictionary
12+
"""Get configuration string from any configuration storing application and return the parsed JSON dictionary
1313
1414
Raises
1515
------

docs/utilities/feature_flags.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ Potential changes to be validated when docs are in a better shape
6666
- [ ] Use `base.py` for interfaces for consistency (e.g. Metrics, Tracer, etc.)
6767
- [ ] Some docstrings and logger refer to AWS AppConfig only (outdated given SchemaFetcher)
6868
- [ ] Review why we're testing a private method(`is_rule_matched`)
69-
70-
**Q: Why is `get_configuration()` public?**
69+
- [x] AppConfig construct parameter names for consistency (e.g. `configuration_name` -> `name`, `service` -> `application`)
70+
- [ ] Review `get_configuration`, `get_json_configuration`
71+
- [ ] Review `get_feature` in favour of `get_feature_toggle`

tests/functional/feature_toggles/test_feature_toggles.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def init_configuration_store(mocker, mock_schema: Dict, config: Config) -> Confi
2121

2222
app_conf_fetcher = AppConfigFetcher(
2323
environment="test_env",
24-
service="test_app",
25-
configuration_name="test_conf_name",
24+
application="test_app",
25+
name="test_conf_name",
2626
cache_seconds=600,
2727
config=config,
2828
)
@@ -35,8 +35,8 @@ def init_fetcher_side_effect(mocker, config: Config, side_effect) -> AppConfigFe
3535
mocked_get_conf.side_effect = side_effect
3636
return AppConfigFetcher(
3737
environment="env",
38-
service="service",
39-
configuration_name="conf",
38+
application="application",
39+
name="conf",
4040
cache_seconds=1,
4141
config=config,
4242
)

0 commit comments

Comments
 (0)