Adds in call to new rate limit method in the redis client

- both V1 and V2 APIs
- Rate limiting wrapped into a new method - check_rate_limiting
	- delegates to the previous daily limit and the new though put limit
- Rate limiting done on key type. Each key has it's own limit (number of requests) and interval (time period of requests)
- Configured in the config. Not done on a per-env basis though could be in the future.
This commit is contained in:
Martyn Inglis
2017-04-24 14:15:08 +01:00
parent 6c703840c2
commit 926b8a60f9
8 changed files with 260 additions and 37 deletions

View File

@@ -21,9 +21,9 @@ from app.notifications.process_client_response import (
from app.notifications.process_notifications import (persist_notification,
send_notification_to_queue,
simulated_recipient)
from app.notifications.validators import (check_service_message_limit,
from app.notifications.validators import (check_service_over_daily_message_limit,
check_template_is_for_notification_type,
check_template_is_active)
check_template_is_active, check_rate_limiting)
from app.schemas import (
email_notification_schema,
sms_template_notification_schema,
@@ -107,7 +107,7 @@ def send_notification(notification_type):
if errors:
raise InvalidRequest(errors, status_code=400)
check_service_message_limit(api_user.key_type, service)
check_rate_limiting(service, api_user)
template = templates_dao.dao_get_template_by_id_and_service_id(template_id=notification_form['template'],
service_id=service.id)