Review feedback: retries settings

This commit is contained in:
Neil Martinsen-Burrell 2023-02-14 15:11:05 -06:00
parent 459e753edd
commit 65fd8d3893
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
2 changed files with 6 additions and 1 deletions

View file

@ -20,6 +20,9 @@ import environs
from base64 import b64decode
from cfenv import AppEnv # type: ignore
from pathlib import Path
from typing import Final
from botocore.config import Config
# # # ###
# Setup code goes here #
@ -221,9 +224,10 @@ AWS_ACCESS_KEY_ID = secret_aws_ses_key_id
AWS_SECRET_ACCESS_KEY = secret_aws_ses_key
AWS_REGION = "us-gov-west-1"
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/retries.html#standard-retry-mode
AWS_RETRY_MODE = "standard"
AWS_RETRY_MODE: Final = "standard"
# base 2 exponential backoff with max of 20 seconds:
AWS_MAX_ATTEMPTS = 3
BOTO_CONFIG = Config(retries={"mode": AWS_RETRY_MODE, "max_attempts": AWS_MAX_ATTEMPTS})
# email address to use for various automated correspondence
# TODO: pick something sensible here

View file

@ -29,6 +29,7 @@ def send_templated_email(template_name: str, to_address: str, context={}):
region_name=settings.AWS_REGION,
aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
config=settings.BOTO_CONFIG,
)
except Exception as exc:
raise EmailSendingError("Could not access the SES client.") from exc