/notifyone-gateway

Primary LanguagePythonApache License 2.0Apache-2.0

Introduction

This repository is the part of the open source NotifyOne project.

'notifyone-gateway' provides the gateway implementation in the NotifyOne project.

Gateway acts as the single point of contact in the NotifyOne notification system and exposes APIs required to send notifications and track notification statuses.

Tech Stack

  • Python - version 3.9.10
  • Framework - torpedo [ A lightweight wrapper around the open source Sanic framework ]

Tools & Technologies

  • AWS SQS - for asynchronous processing of the notifications and status updates
  • Sanic OpenApi - for automatic OAS3 documentation of the APIs & out of the box Swagger UI

Configurations Available

  • For the list of all available keys, checkout the Config Template file.
  • Config Template provides a template (actual keys, dummy values) for the actual config file.
  • The actual config.json file must be generated by the service owner with the real values.

Config Keys

config.NAME     : Name of the service
config.HOST     : Host name for interface binding. Default value - 0.0.0.0
config.PORT     : Port for the service
config.WORKER   : Number of Sanic works. Default is 1
config.DEBUG    : Available values [true/false]. If set to true, the service runs in DEBUG mode
config.TIMEOUT  : Default timeout for all the http APIs exposed
config.SENTRY   : Sentry configuraition details. Leave it empty if sentry integration is not needed
config.APM      : APM configurtion. Leave it empty if APM integration is not needed
config.NOTIFICATION_SERVICE : Host and Timeout configurations for notifyone-core (https://github.com/tata1mg/notifyone-core)
config.NOTIFICATION_SERVICE.HOST : notifyone-core service host
config.NOTIFICATION_SERVICE.TIMEOUT : timeout in seconds for APIs calls to notifyone-core service
config.TRIGGER_NOTIFICATIONS : Destination details for each priority.
                                High, medium and low priority events are processed asynchronously using a AWS SQS queue
                                Cirtical priority events are processed synchronously using an API call to notifyone-core service
config.TRIGGER_NOTIFICATIONS.SQS : SQS configuration for hign, medium and low priority events.
config.TRIGGER_NOTIFICATIONS.CRITICAL_PRIORITY.HOST : host for notifyone-core service
config.TRIGGER_NOTIFICATIONS.HIGH_PRIORITY.QUEUE_NAME : SQS queue name for high priority events
config.TRIGGER_NOTIFICATIONS.LOW_PRIORITY.QUEUE_NAME : SQS queue name for low priority events
config.TRIGGER_NOTIFICATIONS.MEDIUM_PRIORITY.QUEUE_NAME : SQS queue name for medium priority events

Deployment - stand-alone and container based

Stand-alone deployment

1. git clone https://github.com/tata1mg/notifyone-gateway.git
2. cd notifyone-gateway
3. touch config.json
4. Generate actual keys and values for config.json file. Refer to config_template.json for keys.
5. pip isntall pipenv (if not alread installed)
6. python3 -m pipenv shell
7. python3 -m pipenv install
8. python3 -m app.service

Docker container based deployment

Here, we pre-assume that you have got docker installed on you system and it's up and running
1. git clone https://github.com/tata1mg/notifyone-gateway.git
2. cd notifyone-gateway
3. touch config.json
4. Generate actual keys and values for config.json file. Refer to config_template.json for keys.
5. docker build . --tag notifyone-gateway --build-arg SERVICE_NAME=notifyone_gateway
6. docker run -p <service-host-port>:<service-container-port> --name notifyone-gateway --detach notifyone-gateway

API Document

We have used sanic_openapi to automatically generate the OAS3 specification API documents for the APIs exposed in this service.

Once you are done with the service setup, the API documentation can be accessed at - :/swagger

Example - If you started your service at port number 9402, the documentation can be accessed at - localhost:9401/swagger

Alternatively,

If you wish to have a look at the API documentation without deploying the service, you can use an independent swagger UI to view the documentation by pointing the swagger UI to the api_doc.json file.

Or, import the api_doc.json file into Postman as OAS3 API collection.

Contribution guidelines

Please refer to our Contribution Guidlines for more details.

License

This project is licensed under the Apache-2.0 License.