Skip to content

Commit 64aa998

Browse files
author
Jongmin Kim
committed
feat: add DATABASE_NAME_PREFIX configuration
1 parent 9eed650 commit 64aa998

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/spaceone/core/config/default_conf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,20 @@
6666
OTEL = {
6767
'endpoint': None
6868
}
69+
70+
# Database Configuration
71+
DATABASE_AUTO_CREATE_INDEX = True
72+
DATABASE_NAME_PREFIX = ''
73+
DATABASES = {
74+
'default': {}
75+
}
76+
77+
# Cache Configuration
78+
CACHES = {
79+
'default': {},
80+
'local': {
81+
'backend': 'spaceone.core.cache.local_cache.LocalCache',
82+
'max_size': 128,
83+
'ttl': 300
84+
}
85+
}

src/spaceone/core/model/mongo_model/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ def connect(cls):
140140
else:
141141
del db_conf['read_preference']
142142

143+
db_name: str = db_conf.get('db', '')
144+
db_name_prefix = global_conf.get('DATABASE_NAME_PREFIX', '')
145+
db_conf['db'] = f'{db_name_prefix}{db_name}'
146+
143147
host: str = str(db_conf.get('host', '')).strip()
144148
if host.startswith('mongodb+srv://'):
145149
db_conf['tlsCAFile'] = certifi.where()

0 commit comments

Comments
 (0)