https://github.com/roma-glushko/migdalor
🔆 A Kubernetes native peer discovery and cluster membership management library for your modern Python microservices
https://github.com/roma-glushko/migdalor
kubernetes memebership-management peer-discovery python python-asyncio
Last synced: 28 days ago
JSON representation
🔆 A Kubernetes native peer discovery and cluster membership management library for your modern Python microservices
- Host: GitHub
- URL: https://github.com/roma-glushko/migdalor
- Owner: roma-glushko
- License: mit
- Created: 2023-05-10T19:07:57.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T21:42:40.000Z (almost 2 years ago)
- Last Synced: 2025-02-28T08:33:48.015Z (about 2 months ago)
- Topics: kubernetes, memebership-management, peer-discovery, python, python-asyncio
- Language: Python
- Homepage: https://pypi.org/project/migdalor/
- Size: 93.8 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-distributed-system-projects - Migdalor - a Kubernetes native peer discovery for Python asyncio nodes
README
![]()
# Migdalor
Migdalor is a cluster membership library for modern asyncio Python distributed systems running in Kubernetes.
Migdalor doesn't require a separate broker (e.g. Redis, etcd, Zookeeper, Chubby, etc) to work, but leverage Kubernetes out-of-the-box capabilities
to solve the peer discovery problem.## Features
- 🐍 Modern Asyncio Pythonic API
- 🔦 Brokerless Kubernetes native peer discovery based on headless services
- 🔭 Hooks into membership change events
- 🛠️ Ability to manage membership manually## Installation
```bash
pip install midgalor
# or
# poetry add midgalor
# pdm add midgalor
```## Usage
```python
import migdalorcluster = migdalor.Cluster(
node_address=(node_address), # the current node address (e.g. 127.0.0.1:8001)
discovery=migdalor.KubernetesServiceDiscovery(service_address=cluster_address), # Kubernetes headless service address (e.g. cluster:8000)
## Callbacks on different events
# nodes_added_handlers=[...]
# nodes_removed_handlers=[...],
## Membership update rate
# update_every_secs=10,
)await cluster.start()
# You can also add or remove nodes manually if you support that in your protocol
await cluster.add([("127.0.0.1", 8001)])
# await cluster.remove([("127.0.0.1", 8001)])await cluster.stop()
```Midgalor comes with some comprehensive example to help you get started:
- [The Party Cluster](/examples/party_cluster) - An example of using Migdalor to implement peer discovery in Kubernetes cluster