A lightweight OCaml library for remote procedure calls (RPC) with XML/JSON encoding and code generation via PPX.
OCaml-RPC is a library for implementing remote procedure calls (RPC) in OCaml applications. It provides tools to serialize OCaml data types to and from XML or JSON formats, enabling communication between distributed components. The library solves the problem of building type-safe RPC systems by generating marshaling code from type definitions.
OCaml developers building distributed systems, microservices, or client-server applications that require structured communication with XML or JSON protocols.
Developers choose OCaml-RPC for its lightweight design, strong type safety through PPX-driven code generation, and flexibility in supporting multiple RPC encodings without imposing a specific transport layer.
Light library to deal with RPCs in OCaml
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses PPX extensions like [@@deriving rpc] to automatically generate marshaling functions, ensuring compile-time type safety and reducing manual boilerplate code, as shown in the README's examples.
Provides dedicated Xmlrpc and Jsonrpc modules for handling XML-RPC and JSON-RPC encodings, allowing flexibility in integrating with existing services that use either standard.
The Idl module enables defining RPC interfaces separately from implementations, facilitating the generation of client, server, and CLI bindings through functors like GenClient and GenServer.
Supports @key annotations to map OCaml record fields to different keys in RPC representations, easing integration with APIs that have non-standard identifiers, as illustrated in the type derivation examples.
Leaves the transport mechanism entirely to the user, requiring additional work to implement HTTP or other protocols, which adds complexity compared to all-in-one RPC frameworks.
Default Base64 decoding follows strict RFC4648, causing interoperability problems with servers like Python's xmlrpc.client that use RFC2045, as admitted in the README, necessitating custom overrides.
Primarily designed for OCaml ecosystems; while generators like Pythongen can produce bindings for other languages, it's not as seamless or feature-rich as cross-language RPC systems like gRPC.