Skip to main content

EdgeSync

CI PyPI License: MIT Python

A lightweight Python library for reliable data delivery from edge applications to cloud services. EdgeSync provides persistent local queuing, store-and-forward synchronization, automatic retries, and recovery from network or application failures. Built for IoT devices, edge gateways, industrial systems, and any application operating with intermittent connectivity.

Why EdgeSync

Edge applications lose data for the same handful of reasons every time: the network drops, the cloud endpoint is temporarily unavailable, or the process crashes mid-send. EdgeSync solves this with a durable store-and-forward architecture:

  1. Data is persisted locally (SQLite) before anything is sent.
  2. A background worker attempts delivery to the configured destination.
  3. Acknowledged messages are removed from the local queue.
  4. Failed messages stay queued and are retried with backoff.
  5. Pending data survives process crashes and device restarts.

EdgeSync provides at-least-once delivery, not exactly-once — see docs/reliability.md for the exact guarantee and how to build idempotent consumers on top of it.

Install

pip install edgesync

Quickstart

import asyncio
from edgesync import EdgeSync


async def main():
    async with EdgeSync(
        database="edgesync.db",
        endpoint="https://api.example.com/telemetry",
    ) as sync:
        receipt = await sync.publish(
            {
                "device_id": "device-001",
                "temperature": 28.5,
            }
        )
        print(f"queued as {receipt.message_id}")


asyncio.run(main())

That's it: publish() durably persists the message and returns as soon as it's on disk. A background worker delivers it, retrying with exponential backoff on failure, without the caller needing to stay connected or wait for the network.

MQTT

Install the optional extra first:

pip install edgesync[mqtt]

Publishing to MQTT instead of HTTP is the same pattern with a different transport:

from edgesync import EdgeSync
from edgesync.transports.mqtt import MQTTTransport

sync = EdgeSync(
    database="edgesync.db",
    destinations={
        "telemetry": MQTTTransport(
            "broker.example.com",
            "devices/device-001/telemetry",
            qos=1,
            username="device-001",
            password="...",
        ),
    },
    default_destination="telemetry",
)

await sync.publish({"temperature": 28.5})

MQTTTransport only accepts QoS 1 or 2 — QoS 0 publishes are never acknowledged by the broker, so there'd be no way to tell a successful delivery from a lost one, which would break EdgeSync's at-least-once guarantee. Unlike HTTPTransport, MQTT holds a persistent broker connection: EdgeSync.start() still won't raise if the broker is unreachable (data keeps queuing locally either way), and the transport automatically reconnects on the next delivery attempt after a dropped connection or failed publish.

TLS: by default MQTTTransport connects in plaintext on port 1883. To connect over TLS, pass tls_params (an aiomqtt.TLSParameters) and switch to the broker's TLS port, conventionally 8883:

import aiomqtt
from edgesync.transports.mqtt import MQTTTransport

MQTTTransport(
    "broker.example.com",
    "devices/device-001/telemetry",
    port=8883,
    tls_params=aiomqtt.TLSParameters(
        ca_certs="/etc/ssl/certs/ca-certificates.crt",
    ),
)

TLSParameters also accepts certfile / keyfile for client-certificate (mutual TLS) authentication. Omit tls_params entirely for an unencrypted connection, e.g. a broker on a trusted local network or a local development/test setup. See the MQTT section of the getting-started guide for further detail.

Usage with FastAPI, Flask, and plain asyncio

EdgeSync is async-native, so it's most at home in an asyncio app or an async framework like FastAPI — start it once, publish from your handlers, close it on shutdown:

# FastAPI
@asynccontextmanager
async def lifespan(app: FastAPI):
    await sync.start()
    yield
    await sync.close()


app = FastAPI(lifespan=lifespan)


@app.post("/telemetry")
async def telemetry(payload: dict):
    receipt = await sync.publish(payload)
    return {"message_id": receipt.message_id}

Flask is synchronous, so it needs a small bridge to run EdgeSync's event loop on a background thread rather than spinning up a new loop per request. See docs/integrations.md for the full FastAPI, Flask, and plain-asyncio guide, including the ready-to-use Flask bridge.

Features

  • Durable local queue — SQLite-backed, survives crashes and restarts.
  • At-least-once delivery — messages are only removed once the destination acknowledges them.
  • Automatic retries — configurable exponential backoff with jitter.
  • Dead-letter queue — messages that exhaust retries or fail permanently are retained for inspection instead of being silently dropped.
  • Multiple destinations — route different message types to different endpoints or transports.
  • Pluggable transports — ships with HTTP and MQTT transports; implement Transport for anything else (gRPC, a message broker, ...).
  • Bounded storage — configurable queue capacity with a choice of overflow policies.
  • Async-native — built on asyncio and httpx.

Documentation

Development

uv sync
uv run pytest
uv run ruff check .
uv run mypy

See CONTRIBUTING.md for the full workflow.

License

MIT — see LICENSE.

Download files

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

Source Distribution

edgesync-0.3.2.tar.gz (100.1 kB view details)

Uploaded Source

Built Distribution

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

edgesync-0.3.2-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file edgesync-0.3.2.tar.gz.

File metadata

  • Download URL: edgesync-0.3.2.tar.gz
  • Upload date:
  • Size: 100.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for edgesync-0.3.2.tar.gz
Algorithm Hash digest
SHA256 3120d4ce27a5ab5ceaad2ac87f2615dcfdda6261626ad518b90a6e841b911032
MD5 2187289dbd036f5565ab96d597a0fe67
BLAKE2b-256 b69110bb38f8f573b7d468f5cfc3a0d55b0682bc654e288fd1ff6a4cab0068c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for edgesync-0.3.2.tar.gz:

Publisher: release.yml on adhuldas/EdgeSync

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

File details

Details for the file edgesync-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: edgesync-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for edgesync-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 02067f5c7082e529c48e3e26588c91d3d19514724916f8e1884d875d759bfd3d
MD5 a4606a31685d4bec6c264bfdde8abe85
BLAKE2b-256 f4f2bcc8f1dbe463c1d7d12f8a9183de6aadbb979e36b56d893a1bd7f742ac02

See more details on using hashes here.

Provenance

The following attestation bundles were made for edgesync-0.3.2-py3-none-any.whl:

Publisher: release.yml on adhuldas/EdgeSync

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

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 files

0.3.1

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page