Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1316)

Unified Diff: appengine/gce-backend/config.py

Issue 2247443002: Adds settings.cfg for gce-backend. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@gce_config_refactor
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/gce-backend/main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/gce-backend/config.py
diff --git a/appengine/gce-backend/config.py b/appengine/gce-backend/config.py
index 19a5e28238a30078a61ca3583ad7e741019a5820..63f4326458925255e7f15ecde83513350a1be786 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):
@@ -140,3 +142,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)
+ 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]
« no previous file with comments | « no previous file | appengine/gce-backend/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698