Skip to main content

nacos-client-py

安装

pip install nacos-client-py

使用说明

配置项

# nacos 服务配置
SERVER_ADDRESSES = ""
NAMESPACE = ""
USERNAME = ""
PASSWORD = ""

# 服务名
SERVICE_NAME = ""
# 服务端口
SERVICE_PORT = 8080

服务注册

import config
from nacos_client import NacosClient, get_local_ip

nc = NacosClient(config.SERVER_ADDRESSES, config.NAMESPACE, config.USERNAME, config.PASSWORD)

# 服务注册
nc.register(config.SERVICE_NAME, get_local_ip(), config.SERVICE_PORT)

# 开启调试模式
nc.set_debugging()

服务调用

import config
from nacos_client import NacosClient

nc = NacosClient(config.SERVER_ADDRESSES, config.NAMESPACE, config.USERNAME, config.PASSWORD)


@nc.request(service='test-service', path='/test', method='GET')
def test_get():
    pass


@nc.request(service='test-service', path='/test', method='POST')
def test_post():
    pass


# 服务调用 参数传递遵循requests参数规范。
try:
    # get请求参数使用params键传递
    response = test_get(params={'test': 'test'})

    # post表单
    response = test_post(data={'test': 'test'}, headers={'Token': 'test'})

    # post json
    response = test_post(json={'test': 'test'}, timeout=5)

    print(response.json())

except Exception as e:
    print(str(e))

Release files for nacos-client-py 0.0.17

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-py 0.0.17
File Size Uploaded
nacos-client-py-0.0.17.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nacos-client-py 0.0.17
File Interpreter ABI Platform
nacos_client_py-0.0.17-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size:34.2 kB

Release files / nacos-client-py-0.0.17.tar.gz

Download URL nacos-client-py-0.0.17.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
91d4044eab1ca8a49981366f752758f3fdece3ee3852c0783de2fd34a7632f30
BLAKE2b-256 checksum
How to use checksums
5a462f31dd3b628e1eaadc9fd58b8785ba1022c24968c7c792050bb9d4855305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.16

Release files / nacos_client_py-0.0.17-py2.py3-none-any.whl

Download URL nacos_client_py-0.0.17-py2.py3-none-any.whl
Size 18.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
62d9172e0b03475a0193cc67f26a3ed1dd42882235d4044aa51237f9c1a3d4a8
BLAKE2b-256 checksum
How to use checksums
f6209002283934d26b185a86e3a2b07cf3ba74cd70d7b4a2a60838595d50d3b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.0.17 This release

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

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