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.0.tar.gz (24.6 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.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rstmdb-0.2.0.tar.gz
  • Upload date:
  • Size: 24.6 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.0.tar.gz
Algorithm Hash digest
SHA256 8c25713aac58336c19b1dcc1b38c942c026a7890a4dec5935651a696279bf759
MD5 95120647b5157f1a323a7f7cbb3785ba
BLAKE2b-256 44281471007def904199183d0b2f4ff606165e4952b2a04c22c7b7a8605d5e7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rstmdb-0.2.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: rstmdb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11ba24e36322f2eb6b758c4312e0ff27a98baea758080861a3cf3b72c72abe1b
MD5 122061079c75adb4eef27d77cf735b17
BLAKE2b-256 99a3a42474cbd009c23929ccc0dd15eb781b0a4f86cf0240a0578f392bed0c02

See more details on using hashes here.

Provenance

The following attestation bundles were made for rstmdb-0.2.0-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