Skip to main content

embedded-nats

Platform wheels containing nats-server and a small Python manager. JetStream, KV, and Object Store are provided by that one server. The project targets Python 3.12+ on Windows x64, Linux x86_64/aarch64/armv7l, and macOS x86_64/arm64 (macOS 12+).

The package version tracks the server version plus a packaging revision: 2.15.0.3 bundles NATS 2.15.0, packaging revision 3. No Go toolchain is needed to install a wheel. The only Python runtime dependency is pinned nats-py 2.16.0.

This is independent, unofficial packaging of the NATS™ server; it is not produced, sponsored, or endorsed by the NATS project or the Linux Foundation. The maintainer has chosen to retain the embedded-nats name. This choice is not a claim of affiliation or trademark permission.

Example

import asyncio
import os
from pathlib import Path

import nats
from embedded_nats import get_server


async def put_example(url: str, token: str) -> None:
    client = await nats.connect(url, token=token)
    try:
        js = client.jetstream()
        store = await js.create_object_store(bucket="render_results", max_bytes=64 * 1024 * 1024)
        with Path("preview.png").open("rb") as source:
            await store.put("render/immutable-run-id.png", source)
        temporary = Path("preview.download.tmp")
        try:
            with temporary.open("wb") as destination:
                await store.get("render/immutable-run-id.png", writeinto=destination)
            os.replace(temporary, "preview.download.png")
        finally:
            temporary.unlink(missing_ok=True)
        await js.delete_object_store("render_results")  # only for this disposable example
    finally:
        await client.close()


with get_server("./nats-data") as server:
    print(server.url)  # URL never includes the token
    asyncio.run(put_example(server.url, server.auth_token))

The synchronous manager should be started outside an application's asyncio event loop (for example with await asyncio.to_thread(server.start)). It starts a child, waits for an authenticated NATS roundtrip and JetStream API, then owns that child until stop(). A second manager cannot control the same store. By default a previous process marker requires manual recovery; the package does not adopt or kill a process identified only by an old PID.

Opt-in recovery after a crash

NatsServer(store, recover_stale=True) can recover a runtime created by this version after its broker has exited. A separate kernel-held lifetime fence is inherited by the broker itself: flock on Linux/macOS, an exclusive file handle on Windows. Recovery must acquire the same physical fence file while holding the manager lock. Neither a closed port, PID reuse, a clock adjustment nor a different container PID namespace is treated as evidence of death. No orphan process is killed or adopted. server.recovered_generation identifies a recovered generation, or is None for a clean start.

Use a local filesystem, not NFS/SMB or a store shared across machines. Never delete or replace .broker.lease: the persistent file binds the evidence to its kernel object. Legacy/corrupt markers, missing/replaced/copied fence files, permission errors and live holders still require manual recovery. A copied unclean store is not automatically trusted. A reboot releases the kernel fence; it does not erase or repair JetStream data. The package removes only old runtime configuration/port files and the marker, never jetstream/ or buckets.

RecoveryRequired.reason is a diagnostic code; RecoveryRequired.marker_path and server.recovery_marker_path are public diagnostic paths. These fields contain no credentials. A broker that dies during the manager's lifetime still makes stop() report RecoveryRequired; a subsequent opt-in start can recover it.

This proves broker ownership only. Consumers must independently contain their workers and must not delete old staging files just because broker recovery succeeded. There is no automatic replay of consumer commands.

Data and security

The server listens on loopback with token authentication. The token is kept separately from server.url; avoid logging it. Store data remains after a clean restart. The default JetStream sync_interval is always; relaxing it increases the loss window after a crash. Windows managed stop terminates the child, so recovery is tested as a crash, not as graceful server shutdown.

Store directories should be private to the OS user. On POSIX the manager sets its store, runtime and log directories to mode 0700 when they are owned by the current OS user, then verifies the result. Existing directories with broader permissions are repaired automatically; other owners and unsuccessful permission changes are refused. This does not recursively change stored data or modify parent directories. On Windows choose a directory with a user-private ACL, for example inside the user's application data directory. The generated configuration contains the token. The JetStream file budget defaults to 1 GB, memory store to 64 MB, and NATS message payload to 1 MiB. These do not cap the process RSS or all disk overhead. Configure per-bucket max bytes and TTL according to each consumer's artifact lifetime. Object Store is not S3 and does not provide a transaction with your database or physical printer. Download to a temporary file and publish it with an atomic rename only after get() completes and verifies the digest; discard partial temporary files after an error. An interrupted upload is not a committed object; consumers must not infer completion from orphan chunks. Bucket TTL/quota and periodic consumer cleanup remain necessary for abandoned artifacts.

If a process crashes, inspect managed-runtime.json (including child_pid when present), verify that its old NATS process is gone by executable and store path rather than PID alone, and only then remove the marker before restarting. A crash between spawn and marker update can leave child_pid null; inspect the old generation's ports file and OS process list in that case. Keep jetstream/ and all bucket data. A live copy of that directory is not a consistent backup; integration with application backup belongs to the consumer. The package neither installs an OS service nor deletes store data.

Build and verification

scripts/build_wheels.py builds six target binaries from the pinned upstream tag and commit with Go 1.26.10 (source minimum 1.26), then packages each in a fresh staging tree. The exact commit, Go version, target, binary SHA256, and Go module inventory are inside every wheel. Linux wheels are tagged manylinux_2_17 because the Go binary is built with CGO disabled; minimum kernel compatibility is checked separately. macOS uses a 12.0 deployment floor because Go 1.26 does not support macOS 11. Windows requires Windows 10+ or Server 2016+ under that toolchain. These are packaging targets, not a claim of native tests on every platform from one workstation.

python scripts/build_wheels.py all
python -m pytest tests/ -v

Releases are triggered by v<package-version> tags after full wheel and runtime acceptance. The workflow uses the exact tested wheels for both GitHub Releases and PyPI Trusted Publishing. Creating the repository or committing code does not publish a package.

The bundled server is Apache-2.0. See NOTICE, THIRD_PARTY_NOTICES.md, and each wheel's build manifest for the pinned source and dependency inventory.

Metadata

Release files for embedded-nats 2.15.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for embedded-nats 2.15.0.3
File Actions
embedded_nats-2.15.0.3-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for embedded_nats-2.15.0.3-py3-none-win_amd64.whl
embedded_nats-2.15.0.3-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for embedded_nats-2.15.0.3-py3-none-manylinux_2_17_x86_64.whl
embedded_nats-2.15.0.3-py3-none-manylinux_2_17_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details for embedded_nats-2.15.0.3-py3-none-manylinux_2_17_armv7l.whl
embedded_nats-2.15.0.3-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for embedded_nats-2.15.0.3-py3-none-manylinux_2_17_aarch64.whl
embedded_nats-2.15.0.3-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details for embedded_nats-2.15.0.3-py3-none-macosx_12_0_x86_64.whl
embedded_nats-2.15.0.3-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details for embedded_nats-2.15.0.3-py3-none-macosx_12_0_arm64.whl

Total release size: 39.1 MB

Release files / embedded_nats-2.15.0.3-py3-none-win_amd64.whl

Download URL embedded_nats-2.15.0.3-py3-none-win_amd64.whl
Size 6.9 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
cfa7ea4ff8d0e284846b1acdcf5d767e0771ae152f79030892abdb5bcaa82171
BLAKE2b-256 checksum
How to use checksums
020bdfc436872d6b57cac6e516533e192ad6e755c3ac6ff2de457a345761296c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / embedded_nats-2.15.0.3-py3-none-manylinux_2_17_x86_64.whl

Download URL embedded_nats-2.15.0.3-py3-none-manylinux_2_17_x86_64.whl
Size 6.7 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
13fd5823ba341567c94a6756c3a518eeb3c219d4656d2204cca5c3b913317b08
BLAKE2b-256 checksum
How to use checksums
2930dcf9484fe3c83dd52a2b710289549ff9c5de93fa1b960613572eb7b1870b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / embedded_nats-2.15.0.3-py3-none-manylinux_2_17_armv7l.whl

Download URL embedded_nats-2.15.0.3-py3-none-manylinux_2_17_armv7l.whl
Size 6.4 MB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
3b06fbc2a2356a7234c765a5a6b28f2d83dc871f5f22a0cc498d442cb396cbe2
BLAKE2b-256 checksum
How to use checksums
f6f4d7f15eb13f490e08f753ec7a29aeedd48feeb4cb5f37002b8a454e7b6830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / embedded_nats-2.15.0.3-py3-none-manylinux_2_17_aarch64.whl

Download URL embedded_nats-2.15.0.3-py3-none-manylinux_2_17_aarch64.whl
Size 6.0 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
cd5fd5cae32cfff99e156218f9e37ff145ed25e28c3fbbe8f2e6905f1cfe6381
BLAKE2b-256 checksum
How to use checksums
ba818f61f4177c806d295e2355f42b14b6004ba07a8addd2aa7170160edc64b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / embedded_nats-2.15.0.3-py3-none-macosx_12_0_x86_64.whl

Download URL embedded_nats-2.15.0.3-py3-none-macosx_12_0_x86_64.whl
Size 6.8 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
64132c65186040d1a926da28a44676042af2521753319c5950097f1afa0a90aa
BLAKE2b-256 checksum
How to use checksums
108aef6d61271ee7323aed760190821b92ff6f570c94fc1ae73b4658112cc552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / embedded_nats-2.15.0.3-py3-none-macosx_12_0_arm64.whl

Download URL embedded_nats-2.15.0.3-py3-none-macosx_12_0_arm64.whl
Size 6.2 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
a4ab3e7edc663714f328b05b2bccae3b58120aa07e47dbf995038a5e66bfbddd
BLAKE2b-256 checksum
How to use checksums
2bc0804065ad7f91aef4744eb1f64ade9cf104823fabef741d7d5f9ba3da0e82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for embedded-nats 2.15.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for embedded_nats-2.15.0.3-py3-none-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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