-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overriding retry policy for SMS high priority (#2008)
* Overriding retry policy for SMS high priority * Added comments + format * Fixed ordering * mypy: Added typing to the untyped dict * mypy again * Fix existing test with new changes * Fix existing test with new changes * Refactoring: rename method * Refactoring: granular params * Added test around params building for delivery tasks * Changed test for correct value of retry period for sms high * Introducing feature flag for celery retry policies * Changed FF name for custom task celery params * Adding extension to center editor on kb cursor * Forgot the test config to activate env var * Use constants in tests * Reversing env var config enabling logic (but same config) * Arf got trick by Python conditional logic * Print that env var because it aint working * Format * Removing print debug statement * Apply low retry period for the sms high priority lane on celery retry send * Refactoring retry periods for sms high priority * Fix test * Fix sort * Added timonwong.shellcheck shell checker to devcontainer * Removed manually raised exception only meant for testing
- Loading branch information
1 parent
07a7055
commit e461edc
Showing
9 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any, Dict | ||
|
||
from flask import current_app | ||
|
||
from app.config import QueueNames | ||
from app.models import BULK, NORMAL, PRIORITY, SMS_TYPE | ||
|
||
# Default retry periods for sending notifications. | ||
RETRY_DEFAULT = 300 | ||
RETRY_HIGH = 25 | ||
|
||
RETRY_PERIODS = { | ||
BULK: RETRY_DEFAULT, | ||
NORMAL: RETRY_DEFAULT, | ||
PRIORITY: RETRY_HIGH, | ||
} | ||
|
||
|
||
def build_retry_task_params(notification_type: str, notification_process_type: str) -> Dict[str, Any]: | ||
""" | ||
Build task params for the sending parameter retry tasks. | ||
If the notification is a high priority SMS, set the retry policy to retry every 25 seconds | ||
else fall back to the default retry policy of retrying every 5 minutes. | ||
""" | ||
params: dict[str, Any] = {"queue": QueueNames.RETRY} | ||
if current_app.config["FF_CELERY_CUSTOM_TASK_PARAMS"] is False: | ||
return params | ||
|
||
# Overring the retry policy is only supported for SMS for now; | ||
# email support coming later. | ||
if notification_type == SMS_TYPE: | ||
params["countdown"] = RETRY_PERIODS[notification_process_type] | ||
else: | ||
params["countdown"] = RETRY_DEFAULT | ||
return params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters