Skip to content

Commit

Permalink
add boto call latency for sending to internal sms number (#2290)
Browse files Browse the repository at this point in the history
* add boto call latency for sending to internal sms

* format
  • Loading branch information
sastels authored Sep 17, 2024
1 parent f4759d2 commit fb5eac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ class Config(object):
}
CELERY_QUEUES: List[Any] = []
CELERY_DELIVER_SMS_RATE_LIMIT = os.getenv("CELERY_DELIVER_SMS_RATE_LIMIT", "1/s")
AWS_SEND_SMS_BOTO_CALL_LATENCY = os.getenv("AWS_SEND_SMS_BOTO_CALL_LATENCY", 0.06) # average delay in production

CONTACT_FORM_EMAIL_ADDRESS = os.getenv("CONTACT_FORM_EMAIL_ADDRESS", "[email protected]")

Expand Down
10 changes: 7 additions & 3 deletions app/delivery/send_to_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import re
from datetime import datetime
from time import sleep
from typing import Any, Dict, Optional
from uuid import UUID

Expand Down Expand Up @@ -99,13 +100,16 @@ def send_sms_to_provider(notification):

elif (
validate_and_format_phone_number(notification.to, international=notification.international)
== Config.INTERNAL_TEST_NUMBER
== current_app.config["INTERNAL_TEST_NUMBER"]
):
current_app.logger.info(f"notification {notification.id} sending to internal test number. Not sending to AWS")
current_app.logger.info(f"notification {notification.id} sending to internal test number. Not sending to AWS.")
notification.reference = send_sms_response(provider.get_name(), notification.to)
notification.billable_units = template.fragment_count
update_notification_to_sending(notification, provider)

current_app.logger.info(
f"Sleeping {current_app.config['AWS_SEND_SMS_BOTO_CALL_LATENCY']} seconds to simulate AWS boto call latency."
)
sleep(current_app.config["AWS_SEND_SMS_BOTO_CALL_LATENCY"]) # simulate boto3 client send_sms() delay
else:
try:
template_category_id = template_dict.get("template_category_id")
Expand Down

0 comments on commit fb5eac2

Please sign in to comment.