Skip to main content

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


Download files

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

Source Distribution

meshd-2026.0.3.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

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

meshd-2026.0.3-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

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

Hashes for meshd-2026.0.3.tar.gz
Algorithm Hash digest
SHA256 b36d86bbb375b8a8a47d7556bdff71415ade24899fedcf3b331644b93f61e7f9
MD5 ff42c1c7fbf5700fa220dad783aee12c
BLAKE2b-256 0e0d19e5149270073b6cd00b89c93ad029fa037a7c4e39b7d6dd070427f62022

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshd-2026.0.3.tar.gz:

Publisher: python-publish.yml on arnavdas88/meshd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for meshd-2026.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3cf7ecf2607ce2bcb00855add5eae12889a5ab5d2f1f46ceeee56105e8af8793
MD5 369ec12c3c08b00bd64a5e199f9ba332
BLAKE2b-256 0cd05e9de8241e916a5a65603113c80dd10d583e85afb7502c3909c7d4f5dccd

See more details on using hashes here.

Provenance

The following attestation bundles were made for meshd-2026.0.3-py3-none-any.whl:

Publisher: python-publish.yml on arnavdas88/meshd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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