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 f605aed
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Simple Queue

[![Pylint](https://github.com/GussSoares/simple_queue/actions/workflows/pylint.yml/badge.svg?branch=main)](https://github.com/GussSoares/simple_queue/actions/workflows/pylint.yml)


Este projeto consiste em uma implementação simples apresenta o funcionamento de dois serviços.

- [Producer](/producer.py)
Expand Down
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
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
localstack-client==1.39
localstack-client==1.39
pylint==3.0.2

0 comments on commit f605aed

Please sign in to comment.