Skip to main content

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


Download files

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

Source Distribution

unitpulse_discovery-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

unitpulse_discovery-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file unitpulse_discovery-0.1.0.tar.gz.

File metadata

  • Download URL: unitpulse_discovery-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for unitpulse_discovery-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c8090781d17176380ec8b1cdd84a97876d44d8eaf9f0438696dad79f3de28b0
MD5 68d794920d6ef438752624de5afd77f9
BLAKE2b-256 c7bc15d60fd96497ea3363d3a9b1f27b355e3cf2292054be19e36df09339e5fb

See more details on using hashes here.

File details

Details for the file unitpulse_discovery-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for unitpulse_discovery-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 963c4f2088ef02e4d61404f5de735d33c0b301aaee3278930a31d67cbcfafdcb
MD5 290a49e9aab6156ba4b92a29e70965b0
BLAKE2b-256 26e751d3ccfca844847098335574893120e3a01b5e020a3dccada970105857d3

See more details on using hashes here.

Supported by

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