use-nacos
A python nacos client based on the official open-api.
install
pip install use-nacos
usage
config
from use_nacos import NacosClient
client = NacosClient(...)
# publish config
client.config.publish("test_config", "DEFAULT_GROUP", "test_value")
# get config
assert client.config.get("test_config", "DEFAULT_GROUP") == "test_value"
# subscribe config
def config_update(config):
print(config)
client.config.subscribe(
"test_config",
"DEFAULT_GROUP",
callback=config_update
)
instance
from use_nacos import NacosClient
nacos = NacosClient()
nacos.instance.register(
service_name="test",
ip="10.10.10.10",
port=8000,
weight=10.0
)
nacos.instance.heartbeat(
service_name="test",
ip="10.10.10.10",
port=8000,
)
😘support async mode
# example: fastapi
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI
from use_nacos import NacosAsyncClient
def config_update(config):
print(config)
@asynccontextmanager
async def lifespan(app: FastAPI):
nacos = NacosAsyncClient()
config_subscriber = await nacos.config.subscribe(
data_id="test-config",
group="DEFAULT_GROUP",
callback=config_update,
)
yield
config_subscriber.cancel()
app = FastAPI(lifespan=lifespan)
if __name__ == '__main__':
uvicorn.run("in_fastapi:app", host="0.0.0.0", port=1081)
Developing
make install # Run `poetry install`
make lint # Runs bandit and black in check mode
make format # Formats you code with Black
make test # run pytest with coverage
make publish # run `poetry publish --build` to build source and wheel package and publish to pypi
Metadata
Release files for use-nacos 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| use_nacos-0.1.6.tar.gz | 9.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| use_nacos-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.1 kB
Release files / use_nacos-0.1.6.tar.gz
| Download URL | use_nacos-0.1.6.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39fd209d6719d5a554bf5f365668042199ab80d03f95d3829c0f79c077ca3c49
|
|
BLAKE2b-256 checksum How to use checksums |
1eb376c66910f082f73da38f29b6d75a5f152479b16e4a6e1a815aea1da3421d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.10.18 Linux/6.11.0-1015-azure
|
Release files / use_nacos-0.1.6-py3-none-any.whl
| Download URL | use_nacos-0.1.6-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b738918c82f2f2197b9949fac55216dd9aa4ab0648d168964d212a0d64a67ac
|
|
BLAKE2b-256 checksum How to use checksums |
bd9ad4d69b6446431304c13912aa98cc03f7ba52ac01efb80de66cdf1b3923dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.10.18 Linux/6.11.0-1015-azure
|
Security for use-nacos 0.1.6
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.