##// END OF EJS Templates
d-cache: don't init in includeme so we don't trigger s3 connections on startup of rcstack....
super-admin -
r5487:c594e70d default
parent child Browse files
Show More
@@ -1,78 +1,80 b''
1 1 # Copyright (C) 2015-2024 RhodeCode GmbH
2 2 #
3 3 # This program is free software: you can redistribute it and/or modify
4 4 # it under the terms of the GNU Affero General Public License, version 3
5 5 # (only), as published by the Free Software Foundation.
6 6 #
7 7 # This program is distributed in the hope that it will be useful,
8 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 10 # GNU General Public License for more details.
11 11 #
12 12 # You should have received a copy of the GNU Affero General Public License
13 13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 14 #
15 15 # This program is dual-licensed. If you wish to learn more about the
16 16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 18
19 19 import logging
20 20
21 21 from .backends.fanout_cache import FileSystemFanoutCache
22 22 from .backends.objectstore_cache import ObjectStoreCache
23 23
24 24 from .utils import archive_iterator # noqa
25 25 from .lock import ArchiveCacheGenerationLock # noqa
26 26
27 27 log = logging.getLogger(__name__)
28 28
29 29
30 30 cache_meta = None
31 31
32 32
33 33 def includeme(config):
34 return # don't init cache currently for faster startup time
35
34 36 # init our cache at start
35 settings = config.get_settings()
36 get_archival_cache_store(settings)
37 # settings = config.get_settings()
38 # get_archival_cache_store(settings)
37 39
38 40
39 41 def get_archival_config(config):
40 42
41 43 final_config = {
42 44
43 45 }
44 46
45 47 for k, v in config.items():
46 48 if k.startswith('archive_cache'):
47 49 final_config[k] = v
48 50
49 51 return final_config
50 52
51 53
52 54 def get_archival_cache_store(config, always_init=False):
53 55
54 56 global cache_meta
55 57 if cache_meta is not None and not always_init:
56 58 return cache_meta
57 59
58 60 config = get_archival_config(config)
59 61 backend = config['archive_cache.backend.type']
60 62
61 63 archive_cache_locking_url = config['archive_cache.locking.url']
62 64
63 65 match backend:
64 66 case 'filesystem':
65 67 d_cache = FileSystemFanoutCache(
66 68 locking_url=archive_cache_locking_url,
67 69 **config
68 70 )
69 71 case 'objectstore':
70 72 d_cache = ObjectStoreCache(
71 73 locking_url=archive_cache_locking_url,
72 74 **config
73 75 )
74 76 case _:
75 77 raise ValueError(f'archive_cache.backend.type only supports "filesystem" or "objectstore" got {backend} ')
76 78
77 79 cache_meta = d_cache
78 80 return cache_meta
General Comments 0
You need to be logged in to leave comments. Login now