- Made by former gRPC developer with better performance in mind
- "Infinitely faster" than Protobuf (no serialization needed)
- Data types: void, bool, int, float, string, bytes, list, structs, enums, interfaces, generics
- Promise pipelining -- multiple RPC calls in one network round trip
- No encryption or authentication
It's a wrapper around C++ library which uses its own event loop.
-
You're gonna need:
- Visual Studio 2017 with the following build tools:
- Windows 10 SDK (10.0.17763.0)
- Visual C++ Tools for CMake
- CMake (version >= 3.1)
- Visual Studio 2017 with the following build tools:
-
Download and unzip https://capnproto.org/capnproto-c++-win32-0.7.0.zip
-
Go to
capnproto-c++-0.7.0
directory -
Run
cmake -G "Visual Studio 15 2017" -A x64 .
-
Run Visual Studio as admin and open
Cap'n Proto.sln
-
Select
Release
build type -
Build
BUILD_ALL
solution -
Build
INSTALL
solution -
Create a new Python virtual environment (further referred to as
venv
) -
Clone or download Pycapnp
-
Modify
extensions
insetup.py
(lines 138--143) to look like this:extensions = [Extension("capnp.lib.capnp", ["capnp/lib/capnp.cpp"], include_dirs=[".", "C:\Program Files (x86)\Cap'n Proto\include"], library_dirs=["C:\Program Files (x86)\Cap'n Proto\lib"], language='c++', extra_compile_args=['--std=c++11'], libraries=['capnpc', 'capnp-rpc', 'capnp', 'kj-async', 'kj', 'ws2_32', 'Advapi32'])]
-
Activate the virtual env and run
python setup.py install --force-system-libcapnp
-
Good luck!
No code generation is needed, pycapnp does it on the fly.
To start non-encrypted server run:
python python/server.py 127.0.0.1 <PORT>
To start SSL server run:
python python/ssl_server.py 127.0.0.1 <PORT> ./keys/server.crt ./keys/server.key
To start non-encrypted client run:
python python/client.py 127.0.0.1 <PORT>
To start SSL client run:
python python/ssl_client.py 127.0.0.1 <PORT> ./keys/server.crt
The library is future-based and tokio-compatible.
SSL support is provided by tokio-tls or tokio-openssl.
To build the project you need OpenSSL installed. For Windows use this distribution.
Before running cargo build
set OPENSSL_DIR
variable to point to your OpenSSL installation directory.
To re-generate Rust definitions you need capnp
binary (install instruction) and capnpc
crate installed. Once you have these run:
capnp compile -orust:./rust/helloworld/src/ helloworld.capnp
To start non-encrypted server run:
./rust/helloworld/target/debug/server.exe 127.0.0.1:<PORT>
To start native SSL server run:
./rust/helloworld/target/debug/native_ssl_server.exe 127.0.0.1:<PORT> ./keys/server.p12
To start OpenSSL server run:
./rust/helloworld/target/debug/openssl_server.exe 127.0.0.1:<PORT> ./keys/server.crt ./keys/server.key
To start non-encrypted client run:
./rust/helloworld/target/debug/client.exe 127.0.0.1:<PORT>
To start native SSL client run:
./rust/helloworld/target/debug/client.exe 127.0.0.1:<PORT> ./keys/server.crt