Backend-agnostic service discovery and registration SDK
Project description
unitpulse-discovery
Service registration and discovery SDK for Python microservices. Supports Nacos and Consul.
Installation
# With Nacos support
pip install "./unitpulse-discovery[nacos]"
# With all backends
pip install "./unitpulse-discovery[all]"
Usage
from unitpulse_discovery import setup_discovery
setup_discovery(app, backend="nacos", **NACOS_CONFIG)
app.discovery.initialize()
client = app.discovery.get_client()
client.register(service_name="my-service", host="10.0.0.1", port=8080, ephemeral=True)
On shutdown:
client.deregister("my-service", "10.0.0.1", 8080)
Parameters
setup_discovery(app, backend, **config)
| Parameter | Type | Required | Description |
|---|---|---|---|
app |
Flask | FastAPI | Yes | App instance |
backend |
str | Yes | "nacos" or "consul" |
**config |
Backend-specific config (see below) |
Nacos Config
| Key | Type | Default | Description |
|---|---|---|---|
server_addresses |
str | — | Nacos server, e.g. "nacos-server:8848" |
namespace |
str | "public" |
Nacos namespace ID |
username |
str | None |
Auth username |
password |
str | None |
Auth password |
group_name |
str | "DEFAULT_GROUP" |
Service group |
timeout |
int | 5 |
Request timeout (seconds) |
service_name |
str | None |
Ignored by the backend; safe to include for config consolidation |
client.register(...)
| Parameter | Type | Default | Description |
|---|---|---|---|
service_name |
str | — | Service name to register |
host |
str | — | Instance IP |
port |
int | — | Instance port |
metadata |
dict | {} |
Extra metadata (e.g. {"version": "1.0", "weight": 1}) |
ephemeral |
bool | True |
Temporary instance — requires heartbeat; auto-removed on crash |
heartbeat_interval |
int | 5 |
Heartbeat interval in seconds (ephemeral only) |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unitpulse_discovery-0.2.0.tar.gz.
File metadata
- Download URL: unitpulse_discovery-0.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92d303d6920e9a6aec94e19f397d3f24be2856c7212680d7643857ab326b093a
|
|
| MD5 |
a8eab5b22e8b29cb91465c589236ec0b
|
|
| BLAKE2b-256 |
d9922d4bc0bf1470b8b603218e695a3764709942bd4e36a55a4328091f3b01b3
|
File details
Details for the file unitpulse_discovery-0.2.0-py3-none-any.whl.
File metadata
- Download URL: unitpulse_discovery-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e640f5c2828d8ce61f9cd12437dd689d0538284800c6e0ac725ce11419e9b8e9
|
|
| MD5 |
a62decdacf2d8904c38deba7b491a30c
|
|
| BLAKE2b-256 |
9b2caae8bcdaf8945ac289334a9d9387323577e8ad5c876f0c2993cbf536569e
|