make more functional v2
This commit is contained in:
parent
55a0f7c254
commit
dfeb65c900
22
app/main.py
22
app/main.py
@ -14,6 +14,11 @@ logging.basicConfig(stream=sys.stdout,
|
|||||||
|
|
||||||
|
|
||||||
class ServiceListener(Consumer):
|
class ServiceListener(Consumer):
|
||||||
|
# add new services here
|
||||||
|
SERVICES = {
|
||||||
|
FormGenerationService.ACTION: FormGenerationService,
|
||||||
|
AbilityEstimationService.ACTION: AbilityEstimationService
|
||||||
|
}
|
||||||
|
|
||||||
def handle_message(self, body, attributes, messages_attributes):
|
def handle_message(self, body, attributes, messages_attributes):
|
||||||
# gather/manage/process data based on the particular needs
|
# gather/manage/process data based on the particular needs
|
||||||
@ -23,25 +28,20 @@ class ServiceListener(Consumer):
|
|||||||
# but depending on if we can add the tagset to the sqs message body
|
# 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
|
# we either extract that and then delegate to the appropriate service
|
||||||
# or get the action tag from the object through the aws helper function
|
# or get the action tag from the object through the aws helper function
|
||||||
service = None
|
# service = None
|
||||||
key = aws_helper.get_key_from_message(body)
|
key = aws_helper.get_key_from_message(body)
|
||||||
bucket = aws_helper.get_bucket_from_message(body)
|
bucket = aws_helper.get_bucket_from_message(body)
|
||||||
action = aws_helper.get_object_tag(key, bucket, 'action')['Value']
|
action = aws_helper.get_object_tag(key, bucket, 'action')['Value']
|
||||||
|
|
||||||
logging.info(f'Process starting for {action}')
|
logging.info(f'Process starting for {action}')
|
||||||
|
|
||||||
if action == 'formGeneration':
|
if action in self.SERVICES:
|
||||||
service = FormGenerationService(body)
|
service = self.SERVICES[action](body)
|
||||||
elif action == 'abilityEstimation':
|
service.process()
|
||||||
service = AbilityEstimationService(body)
|
|
||||||
|
logging.info('Process complete for %s', service.file_name)
|
||||||
else:
|
else:
|
||||||
logging.error(f'action of type {action} does not exist.')
|
logging.error(f'action of type {action} does not exist.')
|
||||||
return
|
|
||||||
|
|
||||||
service.process()
|
|
||||||
|
|
||||||
logging.info('Process complete for %s', service.file_name)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.info('Starting IRT Service: That Was Rash (v1.4.0)...')
|
logging.info('Starting IRT Service: That Was Rash (v1.4.0)...')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user