Skip to main content

A set of utilities for placing a message onto a queue for an emailer listener to receive

Project description

rabbitmq-email-notifier

python template for etd projects

Using this Repository

Read the wiki in the rabbitmq-email-notifier repo for instructions on how to set up the template and badge for your repository: https://github.com/harvard-lts/rabbitmq-email-notifier/wiki

Local setup

  1. Make a copy of the .env.example to .env and modify the user and password variables.

  2. Start the container

docker-compose -f docker-compose-local.yml up -d --build --force-recreate

Testing

  1. Start the container up as described in the Local Setup instructions.

  2. Exec into the container:

docker exec -it rabbitmq-email-notifier bash
  1. Run the tests
pytest
  1. Stop the container:

Start the container

docker-compose -f docker-compose-local.yml down

Deployment

Dev

Dev deployment will occur using Jenkins. To trigger the development deployment, commit and push to the 'trial' or 'main' branch.

QA

QA is hosted on servers that contain L4 data. Jenkins is not permitted to deploy to these servers so for QA, Jenkins will only perform the build. To deploy:

  1. Commit and push to 'main'.
  2. If any IF changes happened, use ansible deploy commands from the ETD-IF project. Otherwise, manually restart the stack on the server that hosts QA.

Prod

Deploying to prod requires that the code be tagged in 'main'. That means the code should be stable and ready for a release.

  1. Create the tag and push to the repo if this hasn't been done.
  2. Open Jenkins
  3. Click on the "Branches" tab. NOTE: you should see a pipeline with your new tag. (if not, click on the "scan repository now" link in the sidebar.)
  4. Click on the green play (triangle) button to start the build
  5. Follow the build progress using the blue ocean view
  6. The build process should end with a green status. the docker image is now ready for deployment to prod.
  7. Work with ops to deploy to prod using the ETD-IF project.

Prerequisites to running docker locally

  • Requires telemetry/jaeger docker running
  • Make sure .env has JAEGER_NAME and JAEGER_SERVICE_NAME (see .env.example)
    • Note JAEGER_NAME must have local ip (if on vpn go to Cisco Icon -> Show Statistics Window -> Client Address (IPv4)
  • start jaeger docker
  • docker pull jaegertracing/all-in-one:latest followed by
  • docker run -d --name jaeger -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 -e COLLECTOR_OTLP_ENABLED=true -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 4317:4317 -p 4318:4318 -p 14250:14250 -p 14268:14268 -p 14269:14269 -p 9411:9411 jaegertracing/all-in-one:latest
  • You can now run hello world, and do testing

Run hello world example locally

  • Clone this repo from github

  • Create the .env by copying the .example.env cp .env.example .env

  • Replace rabbit connect value with dev values (found in 1Password LTS-ETD)

  • Replace the CONSUME_QUEUE_NAME and PUBLISH_QUEUE_NAME with a unique name for local testing (eg - add your initials to the end of the queue names)

  • Start up docker
    docker-compose -f docker-compose-local.yml up --build -d --force-recreate

  • Bring up DEV ETD Rabbit UI

  • Look for CONSUME_QUEUE_NAME queue

  • Exec into the docker container docker exec -it rabbitmq-email-notifier bash

  • Run invoke task python script python3 scripts/invoke-task.py

  • Look for PUBLISH_QUEUE_NAME queue, and get the message in the RabbitMQ UI

  • and/or tail to see activity

Manually placing a message on the queue

  • Open the queue in the RabbitMQ UI
  • Click on the CONSUME_QUEUE_NAME queue (the name that you assigned this env value to)
  • Open Publish Message
  • Set a property of content_type to application/json
  • Set the Payload to the following JSON content {"id": "da28b429-e006-49a5-ae77-da41b925bd85","task": "rabbitmq-email-notifier.tasks.send_to_base","args": [{"hello":"world"}]}

Unit Testing

  • exec into docker
  • > pytest tests/unit
  • Note, integration tests are run as part of github actions, not locally

Using OpenTelemetry for tracing

This app uses OpenTelemetry (https://opentelemetry.io/) for live tracing. To see how it is implemented in the application, refer to this wiki: https://wiki.harvard.edu/confluence/display/LibraryTechServices/OpenTelemetry

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbitmq-email-notifier-0.0.3.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

rabbitmq_email_notifier-0.0.3-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file rabbitmq-email-notifier-0.0.3.tar.gz.

File metadata

File hashes

Hashes for rabbitmq-email-notifier-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9233b475788717e0b2e5caf938d3c68666248c5fe775089b48c11b2c7a93897a
MD5 bc9ba02f0f0c3500af4dff2068ca5ae8
BLAKE2b-256 970bc751247b3796e56f929a5b0e766cfe034808f9176567e0b11725726e22a4

See more details on using hashes here.

File details

Details for the file rabbitmq_email_notifier-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for rabbitmq_email_notifier-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06538818bd8c20d0035e34fa87d2a0ffa947509e738d4de5dfaba1a2d1ffea8e
MD5 aaff06e4dadc1d2781b59b669d6dd517
BLAKE2b-256 ab0ef8e87a7500caf4eb8a36b20b17e04485ab0e39a09cce564af7ad89491e1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page