From d7b58f56d154a1f94e903f7ac2a5cc83d30e3c67 Mon Sep 17 00:00:00 2001 From: Graham Herceg Date: Fri, 16 Aug 2024 10:48:55 -0400 Subject: [PATCH 1/2] Set repeater rate limit delay in settings.py --- corehq/motech/repeaters/const.py | 5 ++++- settings.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/corehq/motech/repeaters/const.py b/corehq/motech/repeaters/const.py index ddb7e3c43e15..8a6375ef2e7b 100644 --- a/corehq/motech/repeaters/const.py +++ b/corehq/motech/repeaters/const.py @@ -6,7 +6,10 @@ MAX_RETRY_WAIT = timedelta(days=7) MIN_RETRY_WAIT = timedelta(minutes=60) -RATE_LIMITER_DELAY_RANGE = (timedelta(minutes=0), timedelta(minutes=15)) +RATE_LIMITER_DELAY_RANGE = ( + timedelta(minutes=settings.MIN_REPEATER_RATE_LIMIT_DELAY), + timedelta(minutes=settings.MAX_REPEATER_RATE_LIMIT_DELAY), +) CHECK_REPEATERS_INTERVAL = timedelta(minutes=5) CHECK_REPEATERS_PARTITION_COUNT = settings.CHECK_REPEATERS_PARTITION_COUNT CHECK_REPEATERS_KEY = 'check-repeaters-key' diff --git a/settings.py b/settings.py index b9b20795e331..c0c55856e088 100755 --- a/settings.py +++ b/settings.py @@ -847,6 +847,9 @@ # how many tasks to split the check_repeaters process into CHECK_REPEATERS_PARTITION_COUNT = 1 +MIN_REPEATER_RATE_LIMIT_DELAY = 0 # minutes +MAX_REPEATER_RATE_LIMIT_DELAY = 15 # minutes + # If ENABLE_PRELOGIN_SITE is set to true, redirect to Dimagi.com urls ENABLE_PRELOGIN_SITE = False From 52d49d8cf0a6e516b531a7e696cf9a28dd98e62f Mon Sep 17 00:00:00 2001 From: Graham Herceg Date: Fri, 16 Aug 2024 11:58:28 -0400 Subject: [PATCH 2/2] Use defaults with getattr rather than in settings This avoids polluting settings.py with default values that a user will likely never actually need to tweak. --- corehq/motech/repeaters/const.py | 4 ++-- settings.py | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/corehq/motech/repeaters/const.py b/corehq/motech/repeaters/const.py index 8a6375ef2e7b..b2bbda8e44f5 100644 --- a/corehq/motech/repeaters/const.py +++ b/corehq/motech/repeaters/const.py @@ -7,8 +7,8 @@ MAX_RETRY_WAIT = timedelta(days=7) MIN_RETRY_WAIT = timedelta(minutes=60) RATE_LIMITER_DELAY_RANGE = ( - timedelta(minutes=settings.MIN_REPEATER_RATE_LIMIT_DELAY), - timedelta(minutes=settings.MAX_REPEATER_RATE_LIMIT_DELAY), + timedelta(minutes=getattr(settings, 'MIN_REPEATER_RATE_LIMIT_DELAY', 0)), + timedelta(minutes=getattr(settings, 'MAX_REPEATER_RATE_LIMIT_DELAY', 15)), ) CHECK_REPEATERS_INTERVAL = timedelta(minutes=5) CHECK_REPEATERS_PARTITION_COUNT = settings.CHECK_REPEATERS_PARTITION_COUNT diff --git a/settings.py b/settings.py index c0c55856e088..b9b20795e331 100755 --- a/settings.py +++ b/settings.py @@ -847,9 +847,6 @@ # how many tasks to split the check_repeaters process into CHECK_REPEATERS_PARTITION_COUNT = 1 -MIN_REPEATER_RATE_LIMIT_DELAY = 0 # minutes -MAX_REPEATER_RATE_LIMIT_DELAY = 15 # minutes - # If ENABLE_PRELOGIN_SITE is set to true, redirect to Dimagi.com urls ENABLE_PRELOGIN_SITE = False