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

Side by Side Diff: appengine/machine_provider/config.py

Issue 2225263004: Adds config component to Machine Provider (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file.
4
5 """Instance specific settings."""
6
7 import logging
8
9 from components import config
10 from components import net
11 from components import utils
12 from components.config import validation
13
14 from proto import config_pb2
15
16 SETTINGS_CFG_FILENAME = 'settings.cfg'
17 SETTINGS_TS_MON_DEFAULT = True
18
19
20 ConfigApi = config.ConfigApi
21
22
23 @validation.self_rule(SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg)
24 def validate_settings(cfg, ctx):
25 """Validates settings.cfg file against proto message schema."""
26 pass
27
28
29 def _get_settings():
30 """Returns (rev, cfg) where cfg is a parsed SettingsCfg message.
31
32 If config does not exists, returns (None, <cfg with defaults>).
33
34 The config is cached in the datastore.
35 """
36 # store_last_good=True tells config component to update the config file
37 # in a cron job. Here we just read from the datastore.
38 rev, cfg = config.get_self_config(
39 SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg, store_last_good=True)
40 cfg = cfg or config_pb2.SettingsCfg()
41 cfg.enable_ts_monitoring = cfg.enable_ts_monitoring or SETTINGS_TS_MON_DEFAULT
42 return rev, cfg
43
44
45 @utils.cache_with_expiration(60)
46 def settings():
47 """Loads settings from an NDB-based cache or a default one if not present."""
48 return _get_settings()[1]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698