Python client library for rstmdb server using RCP protocol
Project description
rstmdb-py
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
pydanticmodels - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e96180094935b8072583fa2dc493ae7210bd5092da1157d317bf6a88220f67c3
|
|
| MD5 |
2587c1541831ef98f2affe22fa67306f
|
|
| BLAKE2b-256 |
7a542e61d8751833c668587c35fe2ef4092eec24ef4de2765336c3b00c6941d6
|
Provenance
The following attestation bundles were made for rstmdb-0.2.1.tar.gz:
Publisher:
publish.yml on rstmdb/rstmdb-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rstmdb-0.2.1.tar.gz -
Subject digest:
e96180094935b8072583fa2dc493ae7210bd5092da1157d317bf6a88220f67c3 - Sigstore transparency entry: 1123562312
- Sigstore integration time:
-
Permalink:
rstmdb/rstmdb-py@bd466fad06a3db84882140229f8932d3e21e1467 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/rstmdb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd466fad06a3db84882140229f8932d3e21e1467 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2e15cc1c1bc3736b7fda1fb252378b4f12069c3fe4b5f809d709e9202ee6fa1
|
|
| MD5 |
6eb4af50c53c345690efe991d03f2fd7
|
|
| BLAKE2b-256 |
b697775f29725af7c9ed4a6b47b525e6f27c0f814bcb17d06a85fb59cd3aa36c
|
Provenance
The following attestation bundles were made for rstmdb-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on rstmdb/rstmdb-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rstmdb-0.2.1-py3-none-any.whl -
Subject digest:
c2e15cc1c1bc3736b7fda1fb252378b4f12069c3fe4b5f809d709e9202ee6fa1 - Sigstore transparency entry: 1123562372
- Sigstore integration time:
-
Permalink:
rstmdb/rstmdb-py@bd466fad06a3db84882140229f8932d3e21e1467 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/rstmdb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd466fad06a3db84882140229f8932d3e21e1467 -
Trigger Event:
release
-
Statement type: