Configuration

Each microservice needs a config file in yaml or json format to work with it. This configuration contains the Flask settings of your project and the Services.

a simple configuration file could be a config.yaml:

pyms:
  requests: true
  swagger:
    path: ""
    file: "swagger.yaml"
my-ms:
  DEBUG: true
  TESTING: false
  APP_NAME: "Python Microservice"
  APPLICATION_ROOT: ""

or in a config.json:

{
"pyms":{
  "requests": true,
  "swagger": {
    "path": "",
    "file": "swagger.yaml"
    }
  },
"my-ms": {
  "DEBUG": true,
  "TESTIN": false,
  "APP_NAME": "Python Microservice",
  "APPLICATION_ROOT": ""
  }
}

This file could contains this keywords:

pyms block

pyms: all subsets inside this keyword are the settings of this library. Each keyword will be a service of our Microservice class. For example, we declare our microservice class as:

from pyms.flask.app import Microservice
ms = Microservice(service="my-ms", path=__file__)

and a config.yaml file:

pyms:
  requests: true

our object ms has an attribute requests that is a instance of our service requests.

Our microservice block

This part contains all keywords of a Flask Configuration Handling and our constants of the enviroments (local configuration, staging configuration...). Keep in mind that a Flask configuration needs the keywords to be declared as uppercase.

The name of this block is defined when you create the object of Microservice class:

Example 1

from pyms.flask.app import Microservice
ms = Microservice(service="my-personal-microservice", path=__file__)

and a config.yaml file:

my-personal-microservice:
  DEBUG: true
  TESTING: false

Example 2

from pyms.flask.app import Microservice
ms = Microservice(service="ms1-api", path=__file__)

and a config.yaml file:

ms1-api:
  DEBUG: true
  TESTING: false