Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GussSoares committed Dec 3, 2023
1 parent 8b2eeb4 commit 67f86e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions consumer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""Consumer file
"""

import os
import json
import time
Expand All @@ -19,8 +22,8 @@
)
for msg in messages:
parse_message = json.loads(msg.body)

message = json.loads(parse_message['Message'])['message']

print(f"Mensagem recebida: {message}")
msg.delete()
14 changes: 9 additions & 5 deletions producer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Producer file
"""

import json
import os
Expand All @@ -10,15 +12,17 @@


def create_queue():
"""Create initial sns topic and sqs queue
"""
sns_sqs_list = [
'simple-queue',
]
sns = local_boto3(localstack_host='localstack').resource("sns")
sqs = local_boto3(localstack_host='localstack').resource("sqs")
_sns = local_boto3(localstack_host='localstack').resource("sns")
_sqs = local_boto3(localstack_host='localstack').resource("sqs")
sns_client = local_boto3(localstack_host='localstack').client('sns')
for sns_sqs in sns_sqs_list:
sns.create_topic(Name=sns_sqs)
sqs.create_queue(QueueName=sns_sqs)
_sns.create_topic(Name=sns_sqs)
_sqs.create_queue(QueueName=sns_sqs)
sns_client.subscribe(
TopicArn=f'arn:aws:sns:us-east-1:000000000000:{sns_sqs}',
Protocol='sqs',
Expand All @@ -31,7 +35,7 @@ def create_queue():
while True:
sns = boto3.client('sns')
topic = json.loads(os.environ.get('COPILOT_SNS_TOPIC_ARNS'))

message = {"message": f'Eu sou o produtor! Esta é a mensagem {uuid.uuid4()}!'}
response = sns.publish(
TopicArn=topic.get('simple_queue'),
Expand Down

0 comments on commit 67f86e3

Please sign in to comment.