mograph
Dependency Graph Analysis and Processing.
Introduction
This tool allows us to scan a services' spec, then determine in what order we can start them or stop them. In order to make things faster, we can start or stop them in parallel in some cases. Namely:
- Services should be started in parallel if all their dependencies (if any) have already started.
- Services should be stopped in parallel if all their dependents (if any) have already stopped.
Motivation
In a micro-services scenario, we usually have multiple services with various dependencies. This give us many advantages such as loose coupling, high maintainability & testability.
On the other hand, it brings on its own complexity. Services have multiple dependencies between each other, and it can quickly get difficult to manage.
Installation
From the PyPi repository
Use the package manager pip
to install mograph.
pip install mograph
Manually from this repository
You can also clone this repository, install its dependencies and run the tool from there.
# Clone the repository
git clone git@github.com:molamk/mograph.git && cd mograph
# Install the project
python3 setup.py develop
Usage
The program works as follows:
- Load a
yaml
file describing some services with dependencies. - Analyze the dependencies and build the graph.
- Print the starting (or stopping) sequence.
The yaml
file looks something like this:
# services.yaml
mysql:
deps: []
zookeeper:
deps: []
kibana:
deps:
- mysql
fullhouse:
deps:
- kibana
- zookeeper
To run the program, invoke it with either the start
command or stop
:
mograph start ./services.yaml
# or (depending on your configuration)
python3 -m mograph ./services.yaml
The output should be:
START SEQUENCE
0 : ['mysql', 'zookeeper']
1 : ['kibana']
2 : ['fullhouse']
And for the stop command, it should look like this:
STOP SEQUENCE
0 : ['fullhouse']
1 : ['zookeeper', 'kibana']
2 : ['mysql']
Tech Stack
- Implementation in Python 3
- CI/CD with CircleCI
- Test coverage with CodeCov
- Python package repository PyPi
- Documentation hosting with ReadTheDocs