[英]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?我只设计了带有微服务的 api 或者我是否为此制作了后端功能。
Is microservices only creating an api.How can I call it in the front end django template?微服务只是创建了一个api。如何在前端django模板中调用它?
You can create particular packages.您可以创建特定的包。
What I do and you can follow:我做什么,你可以遵循:
1. A way to create a django microservice 1.一种创建django微服务的方法
Django is separated by apps, like this you can create each service in each app: Django 由应用程序分隔,这样您可以在每个应用程序中创建每个服务:
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 2.创建一个包
Since they are separated you can remove them from the project for example and create a particular package that can be installed by shell.由于它们是分开的,因此您可以将它们从项目中删除,例如创建一个可以由 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
.例如,您的
app_1
是一项您想单独出售给客户的服务,您可以创建(比如说) app_1_package
。
Here is a link directly from django documentation that explain exactly how to do this. 这是直接来自 django 文档的链接,它准确地解释了如何执行此操作。
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:创建它后,只需为您已经创建的包启动一个 git 存储库,您可以通过 pip 命令安装它,例如:
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.最初可能很难,但仅供您个人使用和/或您的客户使用,例如,您不需要上传到 Pypi。
3. Remotely adding the packages 3.远程添加包
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.这是我不太了解的部分,但我可以告诉基础设施人员在我工作的地方做的方式是在
.sh
添加pip install
命令作为 shell 命令来自动安装它。
That all steps you need to create microservices I know in a nutshell.简而言之,我知道创建微服务所需的所有步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.