Skip to main content

Python client library for rstmdb server using RCP protocol

Project description

rstmdb-py

CI Python PyPI License

Python client library for communicating with the rstmdb server using the RCP (rstmdb Command Protocol).

Features

  • Async-first design using asyncio
  • Full feature parity with the Rust client
  • Type hints with pydantic models
  • Support for TLS and mTLS
  • Event streaming with async iterators

Installation

pip install rstmdb

For development:

pip install rstmdb[dev]

Quick Start

import asyncio
from rstmdb import Client

async def main():
    async with Client("127.0.0.1", 7401, token="my-secret-token") as client:
        # Create machine
        await client.put_machine("order", 1, {
            "states": ["created", "paid", "shipped"],
            "initial": "created",
            "transitions": [
                {"from": "created", "event": "PAY", "to": "paid"},
                {"from": "paid", "event": "SHIP", "to": "shipped"},
            ]
        })

        # Create instance
        result = await client.create_instance("order", 1, "order-001")
        print(f"Created: {result.instance_id} in state {result.state}")

        # Apply event
        result = await client.apply_event("order-001", "PAY", {"amount": 99.99})
        print(f"Transition: {result.from_state} -> {result.to_state}")

asyncio.run(main())

Watch Events

import asyncio
from rstmdb import Client

async def main():
    async with Client("127.0.0.1", 7401, token="my-secret-token") as client:
        # Start watching
        sub = await client.watch_all(machines=["order"], to_states=["shipped"])
        print(f"Subscription: {sub.subscription_id}")

        # Process events
        async for event in client.events():
            print(f"Event: {event.instance_id} {event.from_state} -> {event.to_state}")

asyncio.run(main())

TLS/mTLS

from rstmdb import Client

# TLS with CA verification
client = Client(
    "127.0.0.1", 7401,
    token="my-secret-token",
    tls=True,
    ca_cert="./certs/ca-cert.pem",
)

# mTLS
client = Client(
    "127.0.0.1", 7401,
    token="my-secret-token",
    tls=True,
    ca_cert="./certs/ca-cert.pem",
    client_cert="./certs/client-cert.pem",
    client_key="./certs/client-key.pem",
)

# Insecure (dev only)
client = Client(
    "127.0.0.1", 7401,
    token="my-secret-token",
    tls=True,
    insecure=True,
)

Development

# Install development dependencies
pip install -e ".[dev]"

# Run all checks with tox
tox

# Run specific tox environments
tox -e py312        # Run tests with Python 3.12
tox -e lint         # Run linting
tox -e typecheck    # Run type checking
tox -e install      # Verify package installation
tox -e format       # Auto-format code

# Or run tools directly
pytest tests/ -v    # Run tests
mypy src/           # Type checking
ruff check src/     # Linting
ruff format src/    # Formatting

License

MIT

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

rstmdb-0.2.1.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

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

rstmdb-0.2.1-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file rstmdb-0.2.1.tar.gz.

File metadata

  • Download URL: rstmdb-0.2.1.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rstmdb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e96180094935b8072583fa2dc493ae7210bd5092da1157d317bf6a88220f67c3
MD5 2587c1541831ef98f2affe22fa67306f
BLAKE2b-256 7a542e61d8751833c668587c35fe2ef4092eec24ef4de2765336c3b00c6941d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rstmdb-0.2.1.tar.gz:

Publisher: publish.yml on rstmdb/rstmdb-py

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

File details

Details for the file rstmdb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: rstmdb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rstmdb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2e15cc1c1bc3736b7fda1fb252378b4f12069c3fe4b5f809d709e9202ee6fa1
MD5 6eb4af50c53c345690efe991d03f2fd7
BLAKE2b-256 b697775f29725af7c9ed4a6b47b525e6f27c0f814bcb17d06a85fb59cd3aa36c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rstmdb-0.2.1-py3-none-any.whl:

Publisher: publish.yml on rstmdb/rstmdb-py

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