Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: granular env-based solution for connection strings #2918

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading