added methodology for delegating to service, fixed some formatting, cleaned up dangling imports

This commit is contained in:
brmnjsh
2023-09-04 19:50:29 +00:00
parent 8f182ef170
commit 7e68606cc1
4 changed files with 21 additions and 6 deletions

View File

@ -23,7 +23,21 @@ class ServiceListener(Consumer):
# but depending on if we can add the tagset to the sqs message body
# we either extract that and then delegate to the appropriate service
# or get the action tag from the object through the aws helper function
service = FormGenerationService(body)
service = None
key = aws_helper.get_key_from_message(body)
bucket = aws_helper.get_bucket_from_message(body)
action = aws_helper.get_object_tag(key, bucket, 'action')['Value']
logging.info(f'Process starting for {action}')
if action == 'formGeneration':
service = FormGenerationService(body)
elif action == 'abilityEstimation':
service = AbilityEstimationService(body)
else:
logging.error(f'action of type {action} does not exist.')
return
service.process()
logging.info('Process complete for %s', service.file_name)