Skip to content

Commit c4e3c53

Browse files
committed
config: granular env-based solution for connection strings
use invenio-config util to build connection string partially closes: inveniosoftware/helm-invenio#112
1 parent f96a443 commit c4e3c53

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: invenio_app_rdm/config.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@
167167
)
168168
from werkzeug.local import LocalProxy
169169

170+
from invenio_config.utils import build_broker_url, build_db_uri, build_redis_url
171+
170172
from .theme.views import notification_settings
171173
from .users.schemas import NotificationsUserSchema, UserPreferencesNotificationsSchema
172174

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

217-
RATELIMIT_STORAGE_URI = "redis://localhost:6379/3"
219+
RATELIMIT_STORAGE_URI = build_redis_url(db=3)
218220
"""Storage for ratelimiter."""
219221

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

383-
ACCOUNTS_SESSION_REDIS_URL = "redis://localhost:6379/1"
385+
ACCOUNTS_SESSION_REDIS_URL = build_redis_url(db=1)
384386
"""Redis session storage URL."""
385387

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

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

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

490-
CELERY_RESULT_BACKEND = "redis://localhost:6379/2"
492+
CELERY_RESULT_BACKEND = build_redis_url(db=2)
491493
"""URL of backend for result storage (default is Redis)."""
492494

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

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

691-
CACHE_REDIS_URL = "redis://localhost:6379/0"
691+
CACHE_REDIS_URL = build_redis_url()
692692
"""URL to connect to Redis server."""
693693

694694
CACHE_TYPE = "flask_caching.backends.redis"

0 commit comments

Comments
 (0)