Skip to content

Commit

Permalink
Merge pull request #11 from python-microservices/feature/doc_update
Browse files Browse the repository at this point in the history
Updated doc due to py-ms library separation.
  • Loading branch information
avara1986 committed Nov 22, 2018
2 parents 8636d84 + 7de98f3 commit 5bdd057
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 47 deletions.
Binary file removed docs/_static/aws_alias0.png
Binary file not shown.
Binary file removed docs/_static/aws_alias1.png
Binary file not shown.
Binary file removed docs/_static/aws_alias2.png
Binary file not shown.
Binary file removed docs/_static/aws_environments.png
Binary file not shown.
12 changes: 2 additions & 10 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
Configuration
=============

The project is configured in `project/config.py`. You must set the project name `APP_NAME` and the path prefix
of the project `APPLICATION_ROOT`. This constants is defined in the class Config:

.. code-block:: python
class Config:
DEBUG = False
TESTING = False
APP_NAME = "Template"
APPLICATION_ROOT = "/template"
Project configuration is loaded using py-ms library based on yml or json file.
Some example files are config.yml, config-docker.yml and tests/config-tests.yml.

Documentation
-------------
Expand Down
62 changes: 25 additions & 37 deletions docs/structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ You have a project with this structure:

.. code-block:: bash
manager.py
Dockerfile
LICENSE
manage.py
README.md
requirements.txt
requirements-tests.txt
requirements-docker.txt
service.yaml
setup.py
tests.sh
tox.ini
myms
├ healthcheck
│ └ healthcheck.py
├ logger
│ └ logger.py
├ models
│ └ __init__.py
└ tracer
└ main.py
project
├ __init__.py
├ config.py
Expand All @@ -33,7 +29,8 @@ You have a project with this structure:
└views
├ __init__.py
└ views.py
docs/
tests/
manager.py
Expand All @@ -51,43 +48,34 @@ You can set the host and the port with:
python manage.py runserver -h 0.0.0.0 -p 8080
Common Structure
Common Libraries
----------------

myms/healthcheck/healthcheck.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This views is usually used by Kubernetes, Eureka and other systems to check if our application is up and running
py-ms is a library that contains a set of common features for microservices.

myms/logger/logger.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Print logger in JSON format to send to server like Elasticsearch. Inject span traces in logger
Structure of a project
----------------------

myms/models/__init__.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Initizalize `flask_sqlalchemy.SQLAlchemy object`
For project configuration see :doc:`configuration </configuration>` section.

myms/tracer/main.py
project/models/init_db.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create an injector `flask_opentracing.FlaskTracer` to use in our projects

Structure of a project
----------------------
Initialize `flask_sqlalchemy.SQLAlchemy object`.

project/__init__.py
~~~~~~~~~~~~~~~~~~~
This file init the project with the funcion `create_app`. Initialize the Flask app, register `blueprints <http://flask.pocoo.org/docs/0.12/blueprints/>`_
and intialize all libraries like Swagger, database, the trace system...
project/models/models.py
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Project specific models.

project/config.py
~~~~~~~~~~~~~~~~~
See :doc:`configuration </configuration>` section
project/swagger/swagger.yaml
~~~~~~~~~~~~~
Use to define your rest behaviour, endpoints and routes. See `connexion <http://connexion.readthedocs.io>`_ docs to how add new views.

project/views
~~~~~~~~~~~~~
use views.py or create your file.

swagger/swagger.yaml
~~~~~~~~~~~~~
Use to define your rest behaviour, endpoints and routes. See `connexion <http://connexion.readthedocs.io>`_ docs to how add new views

project/__init__.py
~~~~~~~~~~~~~~~~~~~
This file init the project calling `create_app` method. Initialize the Flask app, register `blueprints <http://flask.pocoo.org/docs/0.12/blueprints/>`_
and initialize all libraries like Swagger, database, trace system, custom logger format, etc.

0 comments on commit 5bdd057

Please sign in to comment.