@@ -18,91 +18,74 @@ a simple configuration file could be a config.yaml:
1818
1919``` yaml
2020pyms :
21- requests : true
22- swagger :
23- path : " "
24- file : " swagger.yaml"
25- my-ms :
26- DEBUG : true
27- TESTING : false
28- APP_NAME : " Python Microservice"
29- APPLICATION_ROOT : " "
21+ services :
22+ requests: true
23+ swagger:
24+ path: ""
25+ file: "swagger.yaml"
26+ config:
27+ debug: true
28+ testing: false
29+ app_name: "Python Microservice"
30+ APPLICATION_ROOT: ""
3031```
3132
3233or in a config.json:
3334
3435``` json
3536{
36- " pyms" :{
37- " requests " : true,
38- " swagger " : {
39- " path " : " " ,
40- " file " : " swagger.yaml"
37+ "pyms" : {
38+ "services" :{
39+ "requests" : true ,
40+ "swagger" : {
41+ "path" : " " ,
42+ "file" : " swagger.yaml"
43+ }
44+ },
45+ "config" : {
46+ "DEBUG" : true ,
47+ "TESTING" : true ,
48+ "APP_NAME" : " Python Microservice" ,
49+ "APPLICATION_ROOT" : " /" ,
50+ "test_var" : " general" ,
51+ "subservice1" : {
52+ "test" : " input"
53+ },
54+ "subservice2" : {
55+ "test" : " output"
56+ }
4157 }
42- },
43- " my-ms " : {
44- " DEBUG " : true,
45- " TESTIN " : false,
46- " APP_NAME " : " Python Microservice" ,
47- " APPLICATION_ROOT " : " "
4858 }
4959}
5060```
5161
5262This file could contains this keywords:
5363
54- ## pyms block
64+ ## pyms - services block
5565
5666``` pyms ``` : all subsets inside this keyword are the settings of this library. Each keyword will be a service of our
5767[ Microservice class] ( ms_class.md ) . For example, we declare our microservice class as:
5868
5969``` python
6070from pyms.flask.app import Microservice
61- ms = Microservice(service = " my-ms " , path = __file__ )
71+ ms = Microservice(path = __file__ )
6272```
6373and a ` config.yaml ` file:
6474
6575``` yaml
6676pyms :
67- requests : true
77+ services :
78+ requests: true
6879```
6980
7081our object ` ms ` has an attribute ` requests ` that is a instance of our service [ requests] ( services.md ) .
7182
72- # # Our microservice block
83+ ## pyms - config block
7384This part contains all keywords of a [ Flask Configuration Handling] ( http://flask.pocoo.org/docs/1.0/config/ ) and our
7485constants of the enviroments (local configuration, staging configuration...). Keep in mind that a Flask configuration needs
75- the keywords to be declared as uppercase.
86+ the keywords to be declared as uppercase. If you defined a variable like ` app_name ` , you will get this with
87+ ` current_app.config["APP_NAME"] `
7688
77- The name of this block is defined when you create the object of [Microservice class](ms_class.md) :
78-
79- # ## Example 1
80- ` ` ` python
81- from pyms.flask.app import Microservice
82- ms = Microservice(service="my-personal-microservice", path=__file__)
83- ` ` `
84- and a `config.yaml` file :
85-
86- ` ` ` yaml
87- my-personal-microservice:
88- DEBUG: true
89- TESTING: false
90- ` ` `
91-
92- # ## Example 2
93- ` ` ` python
94- from pyms.flask.app import Microservice
95- ms = Microservice(service="ms1-api", path=__file__)
96- ` ` `
97- and a `config.yaml` file :
98-
99- ` ` ` yaml
100- ms1-api:
101- DEBUG: true
102- TESTING: false
103- ` ` `
104-
105- You can set this keyword with the environment var **CONFIGMAP_SERVICE**.
10689
10790## Import Configuration
10891With pyms, all configuration is stored as flask configuration and it can be acceded from:
0 commit comments