Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(data-classes): ActiveMQ and RabbitMQ support #770

Merged
merged 9 commits into from
Oct 29, 2021

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Oct 19, 2021

Issue #, if available:

  • #756

Description of changes:

  • - add active mq data class
  • - add rabbit mq data class
  • - update docs
  • - add fixtures
  • - complete test coverage

Rabbit MQ example:

from typing import Dict

from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.data_classes import event_source
from aws_lambda_powertools.utilities.data_classes.rabbit_mq_event import RabbitMQEvent

logger = Logger()

@event_source(data_class=RabbitMQEvent)
def lambda_handle(event: RabbitMQEvent, context):
    for queue_name, messages in event.rmq_messages_by_queue.items():
        logger.debug(f"Messages for queue: {queue_name}")
        for message in messages:
            logger.debug(f"MessageID: {message.basic_properties.message_id}")
            data: Dict = message.json_data
            logger.debug("Process json in base64 encoded data str", data)

Active MQ example:

from typing import Dict

from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.data_classes import event_source
from aws_lambda_powertools.utilities.data_classes.active_mq_event import ActiveMQEvent

logger = Logger()

@event_source(data_class=ActiveMQEvent)
def lambda_handle(event: ActiveMQEvent, context):
    for message in event.messages:
        logger.debug(f"MessageID: {message.message_id}")
        data: Dict = message.json_data
        logger.debug("Process json in base64 encoded data str", data)

Checklist

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 19, 2021
@boring-cyborg boring-cyborg bot added the tests label Oct 19, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2021

Codecov Report

Merging #770 (4096b20) into develop (4c41ec5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop     #770    +/-   ##
=========================================
  Coverage    99.97%   99.98%            
=========================================
  Files          116      118     +2     
  Lines         4939     5088   +149     
  Branches       275      277     +2     
=========================================
+ Hits          4938     5087   +149     
  Partials         1        1            
Impacted Files Coverage Δ
...wertools/utilities/data_classes/active_mq_event.py 100.00% <100.00%> (ø)
...wertools/utilities/data_classes/rabbit_mq_event.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c41ec5...4096b20. Read the comment docs.

@michaelbrewer michaelbrewer marked this pull request as ready for review October 20, 2021 06:22
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Oct 20, 2021
@michaelbrewer michaelbrewer changed the title feat(data-classes): Amazon MQ as an event source for AWS Lambda feat(data-classes): Active MQ & Rabbit MQ as an event source for AWS Lambda Oct 20, 2021
@michaelbrewer
Copy link
Contributor Author

@heitorlessa - this one is also good to go

@heitorlessa
Copy link
Contributor

Amazon MQ/RabbitMQ team confirmed the event complies with their event definition -- Merging this today

@heitorlessa heitorlessa added the feature New feature or functionality label Oct 29, 2021
@heitorlessa heitorlessa changed the title feat(data-classes): Active MQ & Rabbit MQ as an event source for AWS Lambda feat(data-classes): ActiveMQ and RabbitMQ support Oct 29, 2021
@heitorlessa heitorlessa merged commit 1bcd4ff into aws-powertools:develop Oct 29, 2021
@heitorlessa heitorlessa deleted the feat/amazon-mq branch October 29, 2021 09:59
heitorlessa added a commit to gyft/aws-lambda-powertools-python that referenced this pull request Oct 29, 2021
…uter

* michaelbrewer/docs/router:
  feat(data-classes): ActiveMQ and RabbitMQ support (aws-powertools#770)
  feat(appsync): add Router to allow large resolver composition (aws-powertools#776)
  chore(deps-dev): bump mkdocs-material from 7.3.3 to 7.3.5 (aws-powertools#781)
  chore(deps-dev): bump flake8-isort from 4.0.0 to 4.1.1 (aws-powertools#785)
  chore(deps): bump urllib3 from 1.26.4 to 1.26.5 (aws-powertools#787)
  chore(deps-dev): bump flake8-eradicate from 1.1.0 to 1.2.0 (aws-powertools#784)
  chore(deps): bump boto3 from 1.18.61 to 1.19.6 (aws-powertools#783)
  chore(deps-dev): bump pytest-asyncio from 0.15.1 to 0.16.0 (aws-powertools#782)
  docs: fix indentation of SAM snippets in install section (aws-powertools#778)
  Fix middleware sample (aws-powertools#772)
  Removed unused import, added typing imports, fixed typo in example. (aws-powertools#774)
  Fix middleware sample (aws-powertools#772)
  Removed unused import, added typing imports, fixed typo in example. (aws-powertools#774)
  Update docs/core/event_handler/api_gateway.md

# Conflicts:
#	docs/core/event_handler/api_gateway.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants