Skip to main content

mercury-py (Mercury for Python) is a Python based microservice that allow to manage scheduled notifications sending.

Project description

mercury-py logo

mercury-py

mercury-py (Mercury for Python) is a Python based microservice that allow to manage scheduled notifications' sending.

Introduction

The project consists of a Flask-based RESTful Web API, through which it is possible to manage the scheduling of notifications.

SQLite database is used internally.

MongoDB database is used to store scheduled notifications.

The dispatch of notifications is managed by Celery-based submodules:

  • A Celery Beat that acts as an activator for the Workers.
  • A Celery Worker for each category of notification, who takes care of managing the specific type of dispatch.

RabbitMQ message-broker is used for interprocess communications.

Notifications Categories

The categories of notifications that can currently be sent are:

  • Email.

Categories will be implemented:

  • SMS;
  • Push notification - Firebase Cloud Messaging (FCM);
  • Telegram message.

Setup instructions

Getting it

To download mercury, either fork this GitHub repo or simply download it from PyPI via pip:

pip install mercury-py

Install Dependencies

Mercury needs:

  • MongoDB: get it from the official site (https://www.mongodb.com/) or from the official repository of your Linux disto, for example, on Debian-like systems:
sudo apt install mongodb
  • RabbitMQ: get it from the official site (https://www.rabbitmq.com/) or from the official repository of your Linux disto, for example, on Debian-like systems:
sudo apt install rabbitmq-server

After that, to use Mercury, we need to create a RabbitMQ user, a virtual host and allow that user access to that virtual host:

From terminal, type (substitute in appropriate values for [MYUSER] and [MYPASSWORD] below):

sudo rabbitmqctl add_user [MYUSER] [MYPASSWORD]
sudo rabbitmqctl add_vhost mercury
sudo rabbitmqctl set_permissions -p mercury [MYUSER] ".*" ".*" ".*"

See the RabbitMQ Admin Guide for more information about access control (http://www.rabbitmq.com/admin-guide.html#access-control).

Setting up

Copy and paste file config-*.py, from folder configs, into folder mercury-instance and modify it according to your needs.

Configure the Secret Key

SECRET_KEY should be changed to some random bytes in production.

You can use the following command to output a random secret key:

$ python -c 'import os; print(os.urandom(16))'

Then place returned value into your config.py.

Note: Windows Systems

On Windows systems, an additional dependency must be installed in order for Celery-based submodules to function properly.

Download and install Gevent from PyPI via pip:

pip install gevent

And run (Celery Beat and Celery Workers) from terminal:

beat --app=mercury.app.celery --logfile=instance/logs/celerybeat.log --loglevel=DEBUG --pidfile=instance/celerybeat/celerybeat.pid --schedule=instance/celerybeat/celerybeat-schedule.db
worker --app=mercury.app.celery --logfile=instance/logs/celeryworker.log --loglevel=DEBUG --pool=gevent

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

mercury-py-1.0.2.tar.gz (44.6 kB view details)

Uploaded Source

File details

Details for the file mercury-py-1.0.2.tar.gz.

File metadata

  • Download URL: mercury-py-1.0.2.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.2

File hashes

Hashes for mercury-py-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5adb530bbf152e0f277d278647a4a0c86d86b33db5dd4d3ddb87b282fb15cd9c
MD5 312123ebff5fe65a4dfe3ce5fac691a9
BLAKE2b-256 000f6a163763eb51f1d197ce30acfd1c5f4bb3cd03e1c68dbf99fbe0c64a4878

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