A small distributed meshd network package for Fastapi
Project description
Mesh - A Distributed Data Structure
Mesh - Distributed Data Structure for FastAPI Servers
Usage
from meshd.node import Node
app = FastAPI()
node = Node(
name=NAME, # Assign a name to this server
app=app, # The Fastapi application to hook into
action_on_conflict="merge" # Default action for conflict management
)
...
# To join to a cluster
await node.join([url]) # Add the joining url
await node.sync_up() # Sync up the data
await asyncio.sleep(...) # Wait a few seconds for the sync up to finish
...
# Fetch current data
internal_data = node.data.to_dict()
Example Code
import socket
import asyncio
import contextlib
from fastapi import FastAPI
from meshd.node import Node
NAME = socket.gethostname()
@contextlib.asynccontextmanager
async def lifespan(app: FastAPI):
# Startup
# Put some data during startup
await node.put_data({f"__node_{NAME.lower()}__": {"name": NAME, ...}})
yield
# Shutdown
# Remove the data during shutdown
await node.pop_data(f"__node_{NAME}__")
await node.sync_up()
await asyncio.sleep(SLEEP)
app = FastAPI(title=f"Test Server {NAME}", lifespan=lifespan)
node = Node(name=NAME, app=app, action_on_conflict="merge")
@app.get("/")
async def root():
internal_data = node.data.to_dict()
return {"name": NAME, "status": "running", "internal_data": internal_data}
@app.get("/join")
async def join(url: str):
await node.join([url])
await node.sync_up()
await asyncio.sleep(SLEEP)
internal_data = node.data.to_dict()
return {"name": NAME, "status": "running", "internal_data": internal_data}
Local Dev Installation
$ /usr/bin/env /usr/bin/python3 -m pip install --break-system-packages -e .
Example Simulation
$ docker compose up
Roadmap
- Basic Mesh communication
- Packaging as a python package
- Documenting the basic usage code
- Hosting the documentation to be visible
- Adding callbacks to data change
- Video illustration of the state synchronization
- Adding auto-instrumentation
- Adding more examples
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 meshd-2026.0.3.tar.gz.
File metadata
- Download URL: meshd-2026.0.3.tar.gz
- Upload date:
- Size: 34.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b36d86bbb375b8a8a47d7556bdff71415ade24899fedcf3b331644b93f61e7f9
|
|
| MD5 |
ff42c1c7fbf5700fa220dad783aee12c
|
|
| BLAKE2b-256 |
0e0d19e5149270073b6cd00b89c93ad029fa037a7c4e39b7d6dd070427f62022
|
Provenance
The following attestation bundles were made for meshd-2026.0.3.tar.gz:
Publisher:
python-publish.yml on arnavdas88/meshd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
meshd-2026.0.3.tar.gz -
Subject digest:
b36d86bbb375b8a8a47d7556bdff71415ade24899fedcf3b331644b93f61e7f9 - Sigstore transparency entry: 2289805830
- Sigstore integration time:
-
Permalink:
arnavdas88/meshd@b97b61ea3ae3b66588f592bf6c6d2f70c0b02874 -
Branch / Tag:
refs/tags/2026.0.3 - Owner: https://github.com/arnavdas88
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b97b61ea3ae3b66588f592bf6c6d2f70c0b02874 -
Trigger Event:
release
-
Statement type:
File details
Details for the file meshd-2026.0.3-py3-none-any.whl.
File metadata
- Download URL: meshd-2026.0.3-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cf7ecf2607ce2bcb00855add5eae12889a5ab5d2f1f46ceeee56105e8af8793
|
|
| MD5 |
369ec12c3c08b00bd64a5e199f9ba332
|
|
| BLAKE2b-256 |
0cd05e9de8241e916a5a65603113c80dd10d583e85afb7502c3909c7d4f5dccd
|
Provenance
The following attestation bundles were made for meshd-2026.0.3-py3-none-any.whl:
Publisher:
python-publish.yml on arnavdas88/meshd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
meshd-2026.0.3-py3-none-any.whl -
Subject digest:
3cf7ecf2607ce2bcb00855add5eae12889a5ab5d2f1f46ceeee56105e8af8793 - Sigstore transparency entry: 2289805855
- Sigstore integration time:
-
Permalink:
arnavdas88/meshd@b97b61ea3ae3b66588f592bf6c6d2f70c0b02874 -
Branch / Tag:
refs/tags/2026.0.3 - Owner: https://github.com/arnavdas88
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b97b61ea3ae3b66588f592bf6c6d2f70c0b02874 -
Trigger Event:
release
-
Statement type: