Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Mercury release

mercury-py logo

GitHub release (latest by date) PyPI PyPI - Status

PyPI - Python Version PyPI - Implementation

Flask

GitHub license

GitHub issues

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 distro, 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 distro, 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.

Starting Celery Worker Alternative

Source

You can also embed beat inside the worker by enabling the workers -B option, this is convenient if you’ll never run more than one worker node, but it’s not commonly used and for that reason isn’t recommended for production use:

celery -A mercury.app.celery worker -B --logfile=instance\logs\celery.log --pidfile=instance\celerybeat\celery.pid --schedule=instance\celerybeat\celery-schedule.db --loglevel=DEBUG

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:

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

Release files for mercury-py 1.0.5.dev20230204

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mercury-py 1.0.5.dev20230204
File Size Uploaded
mercury-py-1.0.5.dev20230204.tar.gz 61.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mercury-py 1.0.5.dev20230204
File Interpreter ABI Platform
mercury_py-1.0.5.dev20230204-py3-none-any.whl Python 3 none any Details

Total release size: 131.3 kB

Release files / mercury-py-1.0.5.dev20230204.tar.gz

Download URL mercury-py-1.0.5.dev20230204.tar.gz
Size 61.7 kB
Tags Source
SHA-256 checksum
How to use checksums
12397b50a7a84b55cec966e9a14aca53dee4fc658afe52fddf3b52b80bb6c44a
BLAKE2b-256 checksum
How to use checksums
20010b3b62f59cc15333bcb65cf51067408c68397ab4f7c064d44d0fd694c738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release files / mercury_py-1.0.5.dev20230204-py3-none-any.whl

Download URL mercury_py-1.0.5.dev20230204-py3-none-any.whl
Size 69.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0c2fb706425626fabecfe2f1ab3b7bef5b15f5da9bdbc123042e29a85c881ce
BLAKE2b-256 checksum
How to use checksums
962aab8b6880675963f72029cd53ab4781cf532f591b0d68a80728c33369985f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release history Release notifications | RSS feed

1.0.6

2 release files

1.0.5

2 release files

This release

1.0.4

2 release files

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page