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

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 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]
« 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