Created
August 1, 2022 10:09
-
-
Save shar1z/920a3829c0053ceb156bd2aa59b531e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAX_RETRY_COUNT = 7 | |
DELAY_SECONDS = 5 | |
@exception_handler | |
def handler(event, context): | |
if 'Records' in event: # SQS | |
records = event.get('Records', []) | |
logger.info(f'Received events from SQS with {len(records)} records') | |
for record in records: | |
payload = json.loads(record['body']) | |
event_detail = payload[DETAIL] | |
event_detail_type = payload[DETAIL_TYPE] | |
_handle_event(event_detail_type, event_detail) | |
else: # EventBridge | |
logger.info(f'Received event from EventBridge: {event}') | |
event_detail_type = event[DETAIL_TYPE] | |
event_detail = event[DETAIL] | |
_handle_event(event_detail_type, event_detail) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment