简体   繁体   中英

Django & microservices - How can I design microservices in django

I'm learning Microservices and there s requirement to develop like a Amazon filter and there are other filter as well.How could I able to do it with microservices.

I design only the api with the microservices or do I make back end functionality for that.i have major doubt if I design only the api how could I call in django template?

Is microservices only creating an api.How can I call it in the front end django template?

You can create particular packages.

What I do and you can follow:

1. A way to create a django microservice

Django is separated by apps, like this you can create each service in each app:

ex:

your_main_project/
      |
      |_main_folder/
      |   settings.py
      |   urls.py
      |   ...
      |
      |_app_1/ <--------- app that will become a package/service :)
      |
      |_app_2/

2. Create a package

Since they are separated you can remove them from the project for example and create a particular package that can be installed by shell.

For example your app_1 is a service that you want to sell separately to your customers you can create the (let say) app_1_package .

Here is a link directly from django documentation that explain exactly how to do this.

Once you create it just initiate a git repository for the package you already created and you can install it from a pip command like:

pip install git+https://github.com/your_username/app_1_package.git

It might be hard initially but is only for your personal usage and/or your clients, you dont need to upload to Pypi for example.

3. Remotely adding the packages

This is a part that I do not understand very well but I can tell the way the infra guys do where I work is adding the pip install command inside a .sh as shell command to install it automatically.

That all steps you need to create microservices I know in a nutshell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM