Skip to content

Commit

Permalink
add timeout and write concern to credentials and materialization serv…
Browse files Browse the repository at this point in the history
…ices
  • Loading branch information
dsschult committed Oct 16, 2024
1 parent 163c8e9 commit d2acc21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion iceprod/credentials/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ def __init__(self):
'TOKEN_EXPIRE_BUFFER': 24.0,
'TOKEN_SERVICE_CHECK_INTERVAL': 180,
'DB_URL': 'mongodb://localhost/creds',
'DB_TIMEOUT': 60,
'DB_WRITE_CONCERN': 1,
'STATSD_ADDRESS': '',
'STATSD_PREFIX': 'credentials',
'CI_TESTING': '',
Expand Down Expand Up @@ -466,7 +468,11 @@ def __init__(self):
logging_url = config["DB_URL"].split('@')[-1] if '@' in config["DB_URL"] else config["DB_URL"]
logging.info(f'DB: {logging_url}')
db_url, db_name = config['DB_URL'].rsplit('/', 1)
db = motor.motor_asyncio.AsyncIOMotorClient(db_url)
db = motor.motor_asyncio.AsyncIOMotorClient(
db_url,
timeoutMS=config['DB_TIMEOUT'],
w=config['DB_WRITE_CONCERN'],
)
logging.info(f'DB name: {db_name}')
self.db = db[db_name]
self.indexes = {
Expand Down
8 changes: 7 additions & 1 deletion iceprod/materialization/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ def __init__(self):
'ICEPROD_API_CLIENT_ID': '',
'ICEPROD_API_CLIENT_SECRET': '',
'DB_URL': 'mongodb://localhost/datasets',
'DB_TIMEOUT': 60,
'DB_WRITE_CONCERN': 1,
'STATSD_ADDRESS': '',
'STATSD_PREFIX': 'rest_api',
'CI_TESTING': '',
Expand Down Expand Up @@ -318,7 +320,11 @@ def __init__(self):
logging_url = config["DB_URL"].split('@')[-1] if '@' in config["DB_URL"] else config["DB_URL"]
logging.info(f'DB: {logging_url}')
db_url, db_name = config['DB_URL'].rsplit('/', 1)
db = motor.motor_asyncio.AsyncIOMotorClient(db_url)
db = motor.motor_asyncio.AsyncIOMotorClient(
db_url,
timeoutMS=config['DB_TIMEOUT'],
w=config['DB_WRITE_CONCERN'],
)
logging.info(f'DB name: {db_name}')
self.db = db[db_name]
self.indexes = {
Expand Down

0 comments on commit d2acc21

Please sign in to comment.