Chromium Code Reviews| Index: appengine/gce-backend/config.py |
| diff --git a/appengine/gce-backend/config.py b/appengine/gce-backend/config.py |
| index 745e564c62586b1a509b8079f455cc9ce559c37c..bcc7c8c4daf47b885e2e0fbc62fe02297491b580 100644 |
| --- a/appengine/gce-backend/config.py |
| +++ b/appengine/gce-backend/config.py |
| @@ -17,6 +17,7 @@ import metrics |
| from components import config |
| from components import datastore_utils |
| +from components import utils |
| from components.config import validation |
| from proto import config_pb2 |
| @@ -24,6 +25,7 @@ from proto import config_pb2 |
| TEMPLATES_CFG_FILENAME = 'templates.cfg' |
| MANAGERS_CFG_FILENAME = 'managers.cfg' |
| +SETTINGS_CFG_FILENAME = 'settings.cfg' |
| class Configuration(datastore_utils.config.GlobalConfig): |
| @@ -135,3 +137,25 @@ def validate_manager_config(config, context): |
| zones[manager.template_base_name].add(manager.zone) |
| metrics.config_valid.set(valid, fields={'config': MANAGERS_CFG_FILENAME}) |
| + |
| + |
| +@validation.self_rule(SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg) |
| +def validate_settings_config(config, context): |
| + pass |
| + |
| + |
| +def _get_settings(): |
| + """Returns (rev, cfg) where cfg is a parsed SettingsCfg message. |
| + |
| + The config is cached in the datastore. |
| + """ |
| + rev, cfg = config.get_self_config( |
| + SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg, store_last_good=True) |
|
M-A Ruel
2016/08/12 19:24:25
align arguments at +4
ryanmartens
2016/08/16 17:11:03
Done.
|
| + cfg = cfg or config_pb2.SettingsCfg() |
| + return rev, cfg |
| + |
| + |
| +@utils.cache_with_expiration(60) |
| +def settings(): |
| + """Loads settings from an NDB-based cache or a default one if not present.""" |
| + return _get_settings()[1] |