feature: apply configs via config maker

This commit is contained in:
ievgenii.v 2025-10-24 15:24:45 +03:00
parent 9555056af7
commit 33ca7503ed
3 changed files with 8 additions and 3 deletions

View file

@ -170,6 +170,9 @@ def sanitize_settings_and_apply_defaults(global_config, settings):
# celery
broker_url = settings_maker.make_setting("celery.broker_url", "redis://redis:6379/8", default_when_empty=True)
settings_maker.make_setting("celery.result_backend", broker_url)
settings_maker.make_setting("celery.enable_deduplication", False, parser="bool")
settings_maker.make_setting("celery.deduplicate_lock_store", "redis://redis:6379/9", parser="string")
settings_maker.make_setting("celery.lock_ttl_seconds", 3600, parser="int")
settings_maker.make_setting("exception_tracker.send_email", False, parser="bool")
settings_maker.make_setting("exception_tracker.email_prefix", "[RHODECODE ERROR]", default_when_empty=True)

View file

@ -147,6 +147,9 @@ def get_celery_config(settings):
return key_name[len(pref) :].replace(".", "_").lower()
def type_converter(parsed_key, value):
if not isinstance(value, str):
return value
# cast to int
if value.isdigit():
return int(value)

View file

@ -7,7 +7,6 @@ from celery import Task
from rhodecode import CONFIG
from rhodecode.lib.celerylib import RequestContextTask
from rhodecode.lib.type_utils import str2bool
log = logging.getLogger(__name__)
@ -47,13 +46,13 @@ class UniqueByPayloadTask(Task):
@property
def deduplication_enabled(self):
if self._deduplication_enabled is None:
self._deduplication_enabled = str2bool(CONFIG["celery.enable_deduplication"])
self._deduplication_enabled = CONFIG["celery.enable_deduplication"]
return self._deduplication_enabled
@property
def lock_ttl_seconds(self):
if self._lock_ttl_seconds is None:
self._lock_ttl_seconds = int(CONFIG["celery.lock_ttl_seconds"])
self._lock_ttl_seconds = CONFIG["celery.lock_ttl_seconds"]
return self._lock_ttl_seconds
def _unique_key(self, args, kwargs) -> str: