This microservice is used to filter all the incoming requests.
- It autocompletes the incoming query with
show_more
flag and displays all the possible combinations of the same. - By default it displays top 5 records.
- Further it takes query i.e. the searching criteria (
intent
) andusername
to redirect to the corresponding filter which is configured in mongo_db and returns the result after filtering the output.
Each intent below have separate microservice and must be started in order to work accordingly. If no service is started only intent search will be displayed. Custom intent can be added with some specific structure, refer any of service below. As of now text based search supported, NLP is comming soon....
This is interface to end user on top of RootSevice. RootService feed to messaging platform's. E.g. slack-service, google hangout, skype or any custom conversational UI.
Bot engine is heart rootservice which communicate between messaging platform and each individual service. Bot engine have mainly two parts rootservice
and filterservice
.
- RootService responsible for retrival of suggestion data from mongodb and return to messaging platform.
- FilterService is for fetching data from actual service endpoint like performance, sonar, connectionleak and any custom service.
- python 3.6.0 or above version.
- docker Refer Install Docker documentation.
- [mongo-db] (https://www.mongodb.com/)
$git clone https://github.com/swiftops/root-service.git
Steps :
- Create schema in mongodb with name botengine and import master.json and service.json master.json contains schema for rootservice and service.json contains metadata of each individuak services.
- Open system.properties and change database ip accordingly.
Once done with pre-requisites, execute below command to start root microservice.
docker build -t <image-name>
docker run -p <port_mapping> --name <container_name> -d <image-name>
ex docker run -p 8082:8082 --name ms-rootservice -d <image-name>
To autodeploy your docker container based service on server used below steps
- Need to configure Gitlab Runner to execute Gitlab CI/CD Pipeline. See Gitlab Config
As soon as you configure runner auto deployment will start as you commited the code in repository. refer .gitlab-ci.yml file.
- Open system.properties edit database ip
Virtualenv is the easiest and recommended way to configure a custom Python environment for your services. To install virtualenv execute below command:
$pip3 install virtualenv
Version can be verified for virtual environment with below command
$virtualenv --version
Create a virtual environment for a project:
$ cd <my_project_folder>
$ virtualenv virtenv
virtualenv virtenv
will create a folder in the current directory which will contain the Python executable files, and a copy of the pip library which you can use to install other packages. The name of the virtual environment (in this case, it was virtenv
) can be anything; omitting the name will place the files in the current directory instead.
This creates a copy of Python in whichever directory you ran the command in, placing it in a folder named virtenv
.
You can also use the Python interpreter of your choice (like python3.6).
$virtualenv -p /usr/bin/python3.6 virtenv
To begin using the virtual environment, it needs to be activated:
$ source virtenv/bin/activate
The name of the current virtual environment will now appear on the left of the prompt (e.g. (virtenv)Your-Computer:your_project UserName$) to let you know that it’s active. From now on, any package that you install using pip will be placed in the virtenv folder, isolated from the global Python installation. You can add python packages needed in your microservice decelopment within virtualenv.
pip install -r requirements.txt
python services.py
Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries.It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself. http://flask.pocoo.org/docs/1.0/quickstart/
The Gunicorn "Green Unicorn" (pronounced gee-unicorn)[2] is a Python Web Server Gateway Interface (WSGI) HTTP server.
- Natively supports [WSGI] (https://wsgi.readthedocs.io/en/latest/what.html) , [web2py] (http://www.web2py.com/) and [Django] (https://www.djangoproject.com/).
- Automatic worker process management
- Simple Python configuration
- Multiple worker configurations
- Various server hooks for extensibility
- Compatible with Python 2.6+ and Python 3.2+[4] http://docs.gunicorn.org/en/stable/configure.html