Skip to content

Matchmaker of subscriptions to telemetry, events (and alike) and notifications generation micro-service

License

Notifications You must be signed in to change notification settings

nuvla/subs-notifs

Repository files navigation

Matchmaker of subscriptions to telemetry, events (and alike) and notifications generation micro-service

Maintenance GitHub issues Docker pulls Docker image size

CI Build CI Release

This repository contains the source code for the micro-service for matchmaking the subscriptions to the telemetry, events and alike and generating notifications.

This microservice is a component of the Nuvla service.


NOTE: this microservice is part of a loosely coupled architecture, thus when deployed by itself, it might not provide all of its functionalities. Please refer to https://github.com/nuvla/deployment for a fully functional deployment


Running tests and validation

Unitests

Use the same Python version as defined in Dockerfile. Create a virtual environment with the correct Python veresion and run tests in it.

On the example of pyenv and Python 3.8.12.

pyenv virtualenv 3.8.12 nuvla-subs-notifs-py3.8.12
pyenv activate nuvla-subs-notifs-py3.8.12

Run tests in code/ folder.

cd code/
export PYTHONPATH=$(pwd):$PYTHONPATH
pip install -r requirements.tests.txt
pytest tests/ --junitxml=test-report.xml -v

Validation on a development instance

To validate the time window based resets of the data use https://github.com/wolfcw/libfaketime. When the libfaketime library is installed and is in the LD path, all the time related syscalls from your app will be reporting the time you define.

Below is the generic example of the installation and usage.

Installation example

apk add git make gcc musl-dev
cd /
git clone https://github.com/wolfcw/libfaketime.git
cd /libfaketime/src
make install

Usage example

$ date
Wed Jan  4 15:53:47 UTC 2023
$ export LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1
$ export FAKETIME="+15d"
$ date
Thu Jan 19 15:53:52 UTC 2023
$

This is the option to set the time dynamically on already running application in a container (for example).

$ echo '@2023-02-15 00:00:00' > /etc/faketimerc

Image for validation

Use Dockerfile.faketime file to build an image for validation. Start the image as usual. And when needed, exec into the container and create /etc/faketimerc with the required date. Update /etc/faketimerc to set new dates as needed.

$ docker exec -it -u0 <container-id> bash 
container ~ $ echo '@2023-03-25 01:00:00' > /etc/faketimerc

Building

If you're developing and testing locally in your own machine, simply run docker build .

If you're developing in a non-main branch, please push your changes to the respective branch, and wait for CI to finish the automated build. You'll find your Docker image in the nuvladev organization in Docker hub, names as nuvladev/subs-notifs:<branch>.

Deployment

The service will only work if deployed along with other Nuvla services. See Nuvla deployment for details.

Prerequisites

  • Docker (version 18 or higher)
  • Docker Compose (version 1.23.2 or higher)

Environment variables

Env. variable Description
KAFKA_BOOTSTRAP_SERVERS Comma separated list of Kafka endpoints (eg. kafka1:9092,kafka2:9092)
ES_HOSTS Comma separated list of Elasticsearch endpoints (eg. es1:9200,es2:9200)
XYZ_LOGLEVEL Per-component loglevel. E.g.: DB_LOGLEVEL, MATCHER_LOGLEVEL.
ALL_LOGLEVEL Defines loglevel for all components. XYZ_LOGLEVEL set for a component takes precedence.

Contributing

This is an open-source project, so all community contributions are more than welcome. Please read CONTRIBUTING.md

Copyright

Copyright © 2023, SixSq SA

About

Matchmaker of subscriptions to telemetry, events (and alike) and notifications generation micro-service

Resources

License

Stars

Watchers

Forks

Packages

No packages published