Retry with second lambda if connection error

Note, we assume whenever there is a `FunctionError` that there will be a
payload that contains an `errorMessage` key. It's implied implicitely in
the docs but it's not very explicit.

https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html#API_Invoke_ResponseSyntax
This commit is contained in:
David McDonald
2021-01-11 15:06:24 +00:00
committed by Pea Tyczynska
parent 9da8e54d69
commit 24f52721f3
2 changed files with 74 additions and 2 deletions

View File

@@ -113,7 +113,10 @@ class CBCProxyClientBase(ABC):
result = self._invoke_lambda(self.lambda_name, payload_bytes)
if 'FunctionError' in result:
raise CBCProxyException('Function exited with unhandled exception')
if result['Payload']['errorType'] == "CBCNewConnectionError":
result = self._invoke_lambda(self.failover_lambda_name, payload_bytes)
else:
raise CBCProxyException('Function exited with unhandled exception')
return result