-
Notifications
You must be signed in to change notification settings - Fork 18
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
Overriding retry policy for SMS high priority #2008
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d5ce6a2
Overriding retry policy for SMS high priority
jimleroyer 1099d85
Added comments + format
jimleroyer 990f339
Fixed ordering
jimleroyer 89731a3
mypy: Added typing to the untyped dict
jimleroyer 00457b7
mypy again
jimleroyer 4804bbb
Fix existing test with new changes
jimleroyer 2d95aa0
Fix existing test with new changes
jimleroyer 6cdd740
Merge remote-tracking branch 'origin/main' into feat/decrease-retry-f…
jimleroyer 2dc05b8
Refactoring: rename method
jimleroyer 77dd00f
Refactoring: granular params
jimleroyer d80087a
Added test around params building for delivery tasks
jimleroyer eaebf11
Changed test for correct value of retry period for sms high
jimleroyer cba4269
Introducing feature flag for celery retry policies
jimleroyer 0a5d388
Changed FF name for custom task celery params
jimleroyer 5a144f8
Adding extension to center editor on kb cursor
jimleroyer 74834f7
Forgot the test config to activate env var
jimleroyer 9cc04c2
Use constants in tests
jimleroyer b51f63f
Reversing env var config enabling logic (but same config)
jimleroyer dc81e0d
Arf got trick by Python conditional logic
jimleroyer d36e65f
Print that env var because it aint working
jimleroyer 2fd7be1
Format
jimleroyer 7737bfc
Removing print debug statement
jimleroyer 43b4c47
Merge branch 'main' into feat/decrease-retry-for-sms-high
jimleroyer 77b436f
Apply low retry period for the sms high priority lane on celery retry…
jimleroyer 662112e
Merge remote-tracking branch 'origin/main' into feat/decrease-retry-f…
jimleroyer ff09bed
Merge remote-tracking branch 'origin/feat/decrease-retry-for-sms-high…
jimleroyer 687b790
Refactoring retry periods for sms high priority
jimleroyer ad01cfd
Fix test
jimleroyer c82785f
Fix sort
jimleroyer 887d4f3
Merge remote-tracking branch 'origin/main' into feat/decrease-retry-f…
jimleroyer 57161f1
Added timonwong.shellcheck shell checker to devcontainer
jimleroyer d52c173
Removed manually raised exception only meant for testing
jimleroyer d655af3
Merge remote-tracking branch 'origin/main' into feat/decrease-retry-f…
jimleroyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍