Your task is to create two microservices that exchange data. The microservices should be implemented in Python and should use a queue for communication. The expected output is a complete Python application, including tests and documentation. Requirements
- You should implement two microservices, one to produce data and one to consume data. The producer should be able to generate a message and send it to a queue. The consumer should be able to receive and acknowledge the message from the queue after processing it.
- You should use a queue to communicate between the two microservices. You can use any queue technology that you are familiar with.
- You should use Python 3.9 or higher to implement the microservices.
- You should provide comprehensive tests for your code.
- You should provide documentation for your code, including instructions on how to set up and run the microservices.
- Additional marks will be given for the use of AWS services, Docker, and any Python packaging. Submission You have 24 hours to complete the task. Please submit your code as a Gitlab repository or as a compressed archive file. The repository should include a README file that explains how to set up and run the microservices. Evaluation
- Your submission will be evaluated based on the following criteria:
- Functionality: Does your code meet the requirements and work as expected?
- Code quality: Is your code well-structured, easy to read, and well-documented?
- Testing: Have you provided comprehensive tests for your code?
- Documentation: Have you provided clear and comprehensive documentation for your code?
- Check you have pip installed
- Install poetry
pip install poetry
or
$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
- Install dependencies
poetry install
- Activate your virtual environment by running the command:
poetry shell
- Make sure you have aws credentials
export AWS_ACCESS_KEY_ID=<your-access-key>
export AWS_SECRET_ACCESS_KEY=<your-secret-key>
Replace and with your actual access and secret keys.
Alternatively, you can also create a credentials file and a config file in your home directory (~/.aws/) and set the AWS_PROFILE environment variable to the name of the profile you want to use.
Example .aws
profile:
[default]
aws_access_key_id = <your-access-key>
aws_secret_access_key = <your-secret-key>
- To run your messenger queue, run the following:
python main.py
- Run the following command to run tests
pytest tests
- Dockerize the microservices to build a container image for each microservice
- Include all necessary dependencies and configuration
- Create dockerfile for each microservice
- Create a docker-compose.yml file to define and run multi-container Docker applications.
- Use
localstack
to help us run an SQS container locally for testing purposes - Set environment variables for AWS credentials and region
- Define three services:
- Messenger microservice
- Consumer microservice
- AWS SQS container