Skip to main content

项目说明

一个Django app用于注册nacos

依赖库清单

  • python >= 3.6
  • django >= 2.0
  • requests anyversion

安装环境方式

在对应的python环境中: python setup.py install

功能及作用

1、适用于Django服务程序注册微服务实例至nacos服务中心,实现服务集群健康检测,服务弹性伸缩,压力负载均衡;
2、实现了服务与注册中心的登录授权,服务注册,心跳检测;

引入方式

以下两点同时满足后方可启动服务注册

1、在django对应settings中INSTALLED_APPS添加nacos_app

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.staticfiles',
    'nacos_app.apps.NacosRegisterConfig'
]

2、django程序需要在settings环境配置中写入服务注册的信息

NACOS_SERVER_DISCOVERY = {  
    "server_addr": "",  # nacos服务中心地址,多个英文逗号隔开  
    "namespace": "",                   # 命名空间  
    "group_name": "",                # 分组
    "ip": "",                # 本机ip, 优先级低于socket请求包获取的ip
    "port": "",                       # 本机服务端口
    "service_name": "",           # 本机服务名称
    "ephemeral": ,                   # 是否临时实例,true为临时实例
    "username": "",                    # 拥有对应命名空间权限的账户
    "password": "",               # 密码
    "heartbeat_interval": 5               # 心跳检测间隔,单位秒,nacos默认5s
}

gunicorn web服务启动

gunicorn多个worker模式下启动需要添加--preload参数,由管理进程预加载非函数式编程中的代码块,从而避免多个worker同时加载register
gunicorn backend.wsgi -w 8 -b 0.0.0.0:port -t 600 --preload

1.1.1版本构想

✓ 实现项目功能结构分离
✓ 增加查询服务列表接口功能
✓ 二次封装requests,增加支持LoadBalance的请求发送工具, 可以根据服务名名称自动查找服务ip:port
✓ 定义实体类接收数据类型

Release files for nacos-app 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nacos-app 1.1.4
File Size Uploaded
nacos_app-1.1.4.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nacos-app 1.1.4
File Interpreter ABI Platform
nacos_app-1.1.4-py3-none-any.whl Python 3 none any Details

Total release size:13.5 kB

Release files / nacos_app-1.1.4.tar.gz

Download URL nacos_app-1.1.4.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5076a2f4708bc6b481bb357ada6e4d13badac11a2f4d0efe1783fa97b5260498
BLAKE2b-256 checksum
How to use checksums
6ed2deaee36ca9c9438aff58bfd8912767d76db9b30b46482a891fe8707dd6f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.10

Release files / nacos_app-1.1.4-py3-none-any.whl

Download URL nacos_app-1.1.4-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8decc6b3e86e39e2bdd586e2082de7b53630a7d5c740fe28db791d29db5fc48
BLAKE2b-256 checksum
How to use checksums
90fa385fef2efe5db2ec076c83fc8a5771949b78c91723b7e833560c23202b5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.10

Release history Release notifications | RSS feed

This release

1.1.4 This release

2 release files

1.1.3

2 release files

1.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page