Skip to content

Commit

Permalink
config: granular env-based solution for connection strings
Browse files Browse the repository at this point in the history
use invenio-config util to build connection string

partially closes: inveniosoftware/helm-invenio#112
  • Loading branch information
Samk13 committed Dec 2, 2024
1 parent 399ebb4 commit e0a468e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions invenio_app_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@
)
from werkzeug.local import LocalProxy

from invenio_config.env import build_broker_url, build_db_uri, build_redis_url

from .theme.views import notification_settings
from .users.schemas import NotificationsUserSchema, UserPreferencesNotificationsSchema

Expand Down Expand Up @@ -214,7 +216,7 @@ def _(x):
# =============
# https://flask-limiter.readthedocs.io/en/stable/#configuration

RATELIMIT_STORAGE_URI = "redis://localhost:6379/3"
RATELIMIT_STORAGE_URI = build_redis_url(db=3)
"""Storage for ratelimiter."""

# Increase defaults
Expand Down Expand Up @@ -380,7 +382,7 @@ def files_rest_permission_factory(obj, action):
# See https://invenio-accounts.readthedocs.io/en/latest/configuration.html
# See https://flask-security.readthedocs.io/en/3.0.0/configuration.html

ACCOUNTS_SESSION_REDIS_URL = "redis://localhost:6379/1"
ACCOUNTS_SESSION_REDIS_URL = build_redis_url(db=1)
"""Redis session storage URL."""

ACCOUNTS_USERINFO_HEADERS = True
Expand Down Expand Up @@ -413,7 +415,7 @@ def files_rest_permission_factory(obj, action):
# See docs.celeryproject.org/en/latest/userguide/configuration.html
# See https://flask-celeryext.readthedocs.io/en/latest/

BROKER_URL = "amqp://guest:guest@localhost:5672/"
BROKER_URL = build_broker_url()
"""URL of message broker for Celery 3 (default is RabbitMQ)."""

CELERY_BEAT_SCHEDULE = {
Expand Down Expand Up @@ -487,16 +489,14 @@ def files_rest_permission_factory(obj, action):
CELERY_BROKER_URL = BROKER_URL
"""Same as BROKER_URL to support Celery 4."""

CELERY_RESULT_BACKEND = "redis://localhost:6379/2"
CELERY_RESULT_BACKEND = build_redis_url(db=2)
"""URL of backend for result storage (default is Redis)."""

# Flask-SQLAlchemy
# ================
# See https://flask-sqlalchemy.palletsprojects.com/en/2.x/config/

SQLALCHEMY_DATABASE_URI = (
"postgresql+psycopg2://invenio-app-rdm:invenio-app-rdm@localhost/invenio-app-rdm"
)
SQLALCHEMY_DATABASE_URI = build_db_uri()
"""Database URI including user and password.
Default value is provided to make module testing easier.
Expand Down Expand Up @@ -688,7 +688,7 @@ def files_rest_permission_factory(obj, action):
# =============
# See https://flask-caching.readthedocs.io/en/latest/index.html#configuring-flask-caching # noqa

CACHE_REDIS_URL = "redis://localhost:6379/0"
CACHE_REDIS_URL = build_redis_url()
"""URL to connect to Redis server."""

CACHE_TYPE = "flask_caching.backends.redis"
Expand Down

0 comments on commit e0a468e

Please sign in to comment.