Skip to main content

Polyglot RPC protocol layer (pre-1.0; API may break in minor versions).

Project description

clamator-protocol

Pure JSON-RPC 2.0 protocol primitives plus Pydantic-derived envelope types for clamator. No I/O, ever — anything that touches a network, filesystem, or process belongs in a transport adapter.

Install

pip install clamator-protocol

When you reach for this

  • Defining a Contract (in tests, in custom tooling).
  • Building a custom transport adapter that needs the wire-envelope models, the Transport and Dispatcher interfaces, or the reserved JSON-RPC error codes.

If you only consume generated clients and servers, you don't import this package directly — your transport package (clamator-over-memory, clamator-over-redis) re-exports the few symbols you need.

Defining a contract

The Python counterpart of a Zod contract is a Contract with MethodEntry rows that bind Pydantic models to handler attribute names:

arith = Contract(
    service="arith",
    methods={
        "add": MethodEntry(params_model=AddP, result_model=AddR, handler_attr="add"),
        "ping": MethodEntry(params_model=PingP, result_model=None, handler_attr="ping"),
    },
)

(Verbatim from py/packages/over-memory/tests/test_loopback.py.)

When clamator-protocol is consumed alongside generated wrappers from @clamator/codegen, the Contract and MethodEntry values are produced by codegen — the snippet above is what direct authors of test contracts or custom tooling write.

Key exports

  • Contract, MethodEntry — declare a service's methods and notifications with Pydantic models for params and results.
  • RpcError — the error type you raise from a handler to surface a structured JSON-RPC error to the caller.
  • ClamatorProtocolError, ClamatorTransportError — distinguishable error classes for protocol-level vs. transport-level failures.
  • Transport, Dispatcher — interfaces a custom transport adapter implements.

Codegen workflow

clamator's codegen tool is published to npm (@clamator/codegen) regardless of which language consumes the output. Python users run the TS-side tool against their Zod contract source and consume the emitted Python wrappers from their package. See @clamator/codegen for the CLI invocation.

Links

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

clamator_protocol-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

clamator_protocol-0.1.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file clamator_protocol-0.1.1.tar.gz.

File metadata

  • Download URL: clamator_protocol-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for clamator_protocol-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9f111b3687ced42b0ba15f5362f1b9c312ade0de6186de049c7c4dcb10692cd3
MD5 53fa4ad9a8db6e914c94e582fe4636cd
BLAKE2b-256 2c5a9b3d62e7a7f38d62a1a8dcce8041ace6f1c27177c20fd562a56cf4bd8ead

See more details on using hashes here.

File details

Details for the file clamator_protocol-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for clamator_protocol-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e673949daec7139812f6e9affdb652026b8bc062379a0c7bcb2cf5e0aa1587d
MD5 f5abcb77ccb40bd87e48dce3d5624347
BLAKE2b-256 cde4e0bdb01576954545dd7f61016a14bbb9bfd6844b35a17f3c5c34ada64b46

See more details on using hashes here.

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