Skip to content

Commit

Permalink
Allow read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Yrob committed Mar 30, 2024
1 parent 1e94acc commit dfa70a1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions dcatd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ storage_postgres:
pass: ${DB_PASS}
port: ${DB_PORT}
user: ${DB_USER}
mode: ${DB_MODE:-READWRITE}

storage_swift:
user: ${SWIFT_USER:-catalogus}
Expand Down
3 changes: 2 additions & 1 deletion src/datacatalog/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ async def _on_startup(app):
if r.exception is not None:
raise r.exception
await startup_actions.run_startup_actions(app)
await NotificationHandler(app).setup_notification_handling()
if app.config['storage_postgres'].get("mode", '') != "READONLY":
await NotificationHandler(app).setup_notification_handling()


async def _on_cleanup(app):
Expand Down
2 changes: 1 addition & 1 deletion src/datacatalog/plugins/postgres/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def initialize(app):
raise
else:
break
while connect_attempt_tries_left >= 0:
while connect_attempt_tries_left >= 0 and dbconf.get('mode', 'READWRITE') != "READONLY":
try:
await app['pool'].execute(_Q_CREATE)
await app['pool'].execute(_Q_CREATE_STARTUP_ACTIONS)
Expand Down
5 changes: 5 additions & 0 deletions src/datacatalog/plugins/postgres/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ properties:
type: integer
max_inactive_connection_lifetime:
type: number
mode:
type: string
enum:
- READONLY
- READWRITE
required:
- host
- port
Expand Down

0 comments on commit dfa70a1

Please sign in to comment.