You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""The class Microservice is the core of all microservices built with PyMS.
38
+
You can create a simple microservice such as:
39
+
```python
40
+
from flask import jsonify
41
+
42
+
from pyms.flask.app import Microservice
43
+
44
+
ms = Microservice(service="my-minimal-microservice", path=__file__)
45
+
app = ms.create_app()
46
+
47
+
48
+
@app.route("/")
49
+
def example():
50
+
return jsonify({"main": "hello world"})
51
+
52
+
53
+
if __name__ == '__main__':
54
+
app.run()
55
+
```
56
+
Environments variables of PyMS:
57
+
**CONFIGMAP_FILE**: The path to the configuration file. By default, PyMS search the configuration file in your
58
+
actual folder with the name "config.yml"
59
+
**CONFIGMAP_SERVICE**: the name of the keyword that define the block of key-value of [Flask Configuration Handling](http://flask.pocoo.org/docs/1.0/config/)
60
+
and your own configuration (see the next section to more info)
61
+
62
+
## Create configuration
63
+
Each microservice needs a config file in yaml or json format to work with it. This configuration contains
64
+
the Flask settings of your project and the [Services](services.md). With this way to create configuration files, we
65
+
solve two problems of the [12 Factor apps](https://12factor.net/):
66
+
- Store config out of the code
67
+
- Dev/prod parity: the configuration could be injected and not depends of our code, for example, Kubernetes config maps
68
+
69
+
a simple configuration file could be a config.yaml:
70
+
71
+
```yaml
72
+
pyms:
73
+
requests: true
74
+
swagger:
75
+
path: ""
76
+
file: "swagger.yaml"
77
+
my-ms:
78
+
DEBUG: true
79
+
TESTING: false
80
+
APP_NAME: "Python Microservice"
81
+
APPLICATION_ROOT: ""
82
+
```
83
+
84
+
Services are libraries, resources and extensions added to the Microservice in the configuration file.
85
+
This services are created as an attribute of the [Microservice class](ms_class.md) to use in the code.
86
+
87
+
To add a service check the [configuration section](configuration.md).
88
+
89
+
Current services are swagger, request, tracer, metrics
0 commit comments