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
✓ 定义实体类接收数据类型

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nacos_app-1.1.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nacos_app-1.1.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nacos_app-1.1.4.tar.gz.

File metadata

  • Download URL: nacos_app-1.1.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.10

File hashes

Hashes for nacos_app-1.1.4.tar.gz
Algorithm Hash digest
SHA256 5076a2f4708bc6b481bb357ada6e4d13badac11a2f4d0efe1783fa97b5260498
MD5 a8238e63eb009c56a3cb0f4b0d5778cd
BLAKE2b-256 6ed2deaee36ca9c9438aff58bfd8912767d76db9b30b46482a891fe8707dd6f6

See more details on using hashes here.

File details

Details for the file nacos_app-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: nacos_app-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.10

File hashes

Hashes for nacos_app-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a8decc6b3e86e39e2bdd586e2082de7b53630a7d5c740fe28db791d29db5fc48
MD5 e7d063bb3588d72e101d3daf11864be8
BLAKE2b-256 90fa385fef2efe5db2ec076c83fc8a5771949b78c91723b7e833560c23202b5d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.4 This release

2 files

1.1.3

2 files

1.1.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page