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.0.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.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clamator_protocol-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 029440a865357f319422db78a523918f252445942e12622434f905e89b68df7d
MD5 63acf11b7c3a5e290f420240e78eff30
BLAKE2b-256 922e8c2ce7197e131dd7775650da13d5b576d4697e85c9c2870c6e2b37505e9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for clamator_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5be2c3373844e5a25a26eba9a5ec2465d47ea551b7c02f42b5c92edfd2bf23ef
MD5 fad18d28d34e26134d53f6752c631cb0
BLAKE2b-256 a2b4def2cb31b49dea5de23816d6d99c16722afe72c4abd94a781b4be14d19ba

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