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

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
« no previous file with comments | « appengine/machine_provider/app.yaml ('k') | appengine/machine_provider/cron.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
18
19 ConfigApi = config.ConfigApi
20
21
22 @validation.self_rule(SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg)
23 def validate_settings(cfg, ctx):
24 """Validates settings.cfg file against proto message schema."""
25 pass
26
27
28 def _get_settings():
29 """Returns (rev, cfg) where cfg is a parsed SettingsCfg message.
30
31 If config does not exists, returns (None, <cfg with defaults>).
32
33 The config is cached in the datastore.
34 """
35 # store_last_good=True tells config component to update the config file
36 # in a cron job. Here we just read from the datastore.
37 rev, cfg = config.get_self_config(
38 SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg, store_last_good=True)
39 cfg = cfg or config_pb2.SettingsCfg()
40 return rev, cfg
41
42
43 @utils.cache_with_expiration(60)
44 def settings():
45 """Loads settings from an NDB-based cache or a default one if not present."""
46 return _get_settings()[1]
OLDNEW
« no previous file with comments | « appengine/machine_provider/app.yaml ('k') | appengine/machine_provider/cron.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698