check provider message status etc when sending rather than when retrying

previously if we were deciding whether to retry or not, it meant that
future events wouldn't have context of what the task is doing. We'd
run into issues with not knowing what references to include when
updating/cancelling in future events.

Instead of deciding whether to retry or not, always retry. Instead, when
any event sends, regardless of whether it is a first time or a retry,
check the status of previous events for that broadcast message. There
are a few things that will mean we don't send.

* If the finishes_at time has already elapsed (ie: we have been trying
  to resend this message and haven't had any luck and now the data is
  obselete)
* A previous event has no provider message (this means that we never
  picked the previous event off the queue for some reason)
* A previous event has a provider message that has anything other than
  an ack response. This includes sending (the old message is currently
  being sent), and technical-failure/returned-error (the old message is
  currently in the retry loop, having experienced issues).
This commit is contained in:
Leo Hemsted
2021-02-01 18:54:01 +00:00
parent 96a0935d1c
commit bbae209200
3 changed files with 145 additions and 64 deletions

View File

@@ -64,5 +64,5 @@ def create_broadcast_provider_message(broadcast_event, provider):
@transactional
def update_broadcast_provider_message_status(broadcast_provider_message, status):
def update_broadcast_provider_message_status(broadcast_provider_message, *, status):
broadcast_provider_message.status = status