Skip to main content

nacos_client_python

介绍

服务于nacos的自动化服务注册插件

软件架构

推荐使用py3.7或以上环境使用
基本上是模块化的Nacos open-api,使用参数与open-api一致。 并提供了nacos实例的自动心跳包功能

安装教程

源码安装

git clone https://gitee.com/hubert22/nacos_client_python.git
cd nacos_client_python
python setup.py install

使用说明

请参照client_test运行

或参照

import threading
import time

import uvicorn
from nacos import NacosClient


def regis_server_to_nacos(service_ip, port, service_name, namespaceId):
    """
    注册服务到nacos
    """
    nacos_client = NacosClient('hostname')
    # 注册服务
    try:
        response = nacos_client.instance().register(ip=service_ip, port=port, serviceName=service_name,
                                                    namespaceId=namespaceId, ephemeral=True)
        print('register', response)
    except Exception as e:
        print(e.__str__())
    # 自动心跳包
    try:
        response = nacos_client.instance().auto_beat(ip=service_ip, port=port, serviceName=service_name,
                                                     namespaceId=namespaceId)
        print('send_beat', response)
    except Exception as e:
        print(e.__str__())


if __name__ == '__main__':
    # 运行服务器地址
    service_ip = '192.168.111.89'
    # 运行服务名称
    service_name = 'service.test'
    # 命名空间ID
    namespaceId = 'd479f2e8-62af-47a0-af66-70be48f15080'
    # 运行服务器运行端口
    port = 9014
    regis_server_to_nacos(service_ip, port, service_name, namespaceId)
    # uvicorn运行django程序
    uvicorn.run("hikvim_oa.asgi:application", host="0.0.0.0", port=port, log_level="info", reload=True)

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

Metadata

Release files for nacos-client-python 0.0.1

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-client-python 0.0.1
File Size Uploaded Provenance Actions
nacos_client_python-0.0.1.tar.gz 5.4 kB Without provenance Details for nacos_client_python-0.0.1.tar.gz

Release files / nacos_client_python-0.0.1.tar.gz

Download URL nacos_client_python-0.0.1.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a60beab741d1f3f2d0605bbcd84bc4188d35498e5441adda903948dfc720c069
BLAKE2b-256 checksum
How to use checksums
1ea12e53a24ce57ad383184b40fe9469be9354358c02a098ddfc4d9a907ba4f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.4

Security for nacos-client-python 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

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