Cap'n Proto
Cap’n Proto is a data serialization format and Remote Procedure Call framework for exchanging data between computer programs. The high-level design focuses on speed and security, making it suitable for network as well as inter-process communication. Cap'n Proto was created by the former maintainer of Google's popular Protocol Buffers framework and was designed to avoid some of its perceived shortcomings.
Technical overview
IDL Schema
Like most RPC frameworks dating as far back as Sun RPC and OSF DCE RPC, Cap'n Proto uses an Interface Description Language to generate RPC libraries in a variety of programming languages - automating many low level details such as handling network requests, converting between data types, etc. The Cap'n Proto interface schema uses a C-like syntax and supports common primitives data types, compound types, as well as generics and dynamic types. Cap'n Proto also supports object-oriented features such as multiple inheritance, which has been criticized for its complexity.@0xa558ef006c0c123; # Unique identifiers are manually or automatically assigned to files and compound types
struct Date @0x5c5a558ef006c0c1
struct Contact @0xf032a54bcb3667e0
Unlike other binary serialization protocols such as XMI, Cap'n Proto considers fine-grained data validation at the RPC level an anti-feature that limits a protocol's ability to evolve. This was informed by experiences at Google where simply changing a field from mandatory to optional would cause complex operational failures. Cap'n Proto schemas are designed to be flexible as possible and pushes data validation to the application level, allowing arbitrary renaming of fields, adding new fields, and making concrete types generic. Cap'n Proto does, however, validate pointer bounds and type check individual values when they are first accessed.
Enforcing complex schema constraints would also incur significant overhead, negating the benefits of reusing in-memory data structures and preventing random access to data. Cap'n Proto protocol is theoretically suitable for very fast inter-process communication via immutable shared memory, but as of October 2020 none of the implementations support data passing via shared memory. However, Cap'n Proto is still generally considered faster than Protocol Buffers and similar RPC libraries.
Networking
Cap'n Proto RPC is network aware: supporting both handling of disconnects and promise pipelining, wherein a server pipes the output of one function into another function. This saves a client a round trip per successive call to the server without having to provide a dedicated API for every possible call graph. Cap'n Proto can be layered on top of TLS and support for the Noise Protocol Framework is on the roadmap. Cap'n Proto RPC is transport agnostic, with the mainline implementation supporting WebSockets, HTTP, TCP, and UDP.Capability security
The Cap'n Proto RPC standard has a rich capability security model based on the CapTP protocol used by the E programming language.As of October 2020, the reference implementation only supports level 2.