package capnp-rpc
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4b59a4147cf6e49c650dbfa4cdb918aec3be69cffd1ef6b5c818584464feb987
sha512=69114597e9cd8ad42c72c1751796b216f98f2a9f09f50a0628b4a3259c2f9b169fd47a73be7b76cfda298a6c202bc79762116865272e35ca0d0914242ace34d7
doc/CHANGES.html
v2.1
- Update to mirage-crypto-rng 1.2.0 (@talex5 #313). There is no need to do
Mirage_crypto_rng_eio.runnow. Restorer.Table.createnow takes a switch (@talex5 #306). The table is now cleared when the switch finishes. Avoids having to remember to set this up manually.- Update README now that 2.0 is released (@talex5 #307 #308).
Build and opam metadata:
- OCaml 5.2 is the minimum version (@talex5 #305).
- Update Windows CI (@smorimoto #310 #311).
- Add
x-maintenance-intentto opam files (@talex5 #315, requested by @hannesm). - Remove capnp-rpc-lwt compatibility package (@talex5 #314). The existing release should continue working; no point releasing an unchanged version every time there's a capnp-rpc release.
v2.0
capnp-rpc 2.0 switches from using Lwt to Eio. The capnp-rpc-lwt package is now just Lwt wrappers around the Eio functions in capnp-rpc. This allows libraries using the old Lwt API to be used with applications and libraries using the new Eio one, in the same binary. Because Lwt libraries (using capnp-rpc-lwt) can be used with Eio applications (using capnp-rpc-unix), you should first upgrade your application and then upgrade the libraries afterwards.
It is recommended to upgrade in stages, checking your application still works after each step:
- Upgrade to the latest Lwt version (
opam install capnp-rpc-unix.1.2.4). This uses the new version of mirage-crypto, tls, etc, which may be incompatible with other libraries you are using. Get that sorted out before switching to capnp-rpc 2.0. - Use lwt_eio to allow using Eio and Lwt together in your application. This means replacing your call to
Lwt_main.runwith code to run Eio and Lwt together, as explained at the start of thelwt_eioREADME. - Upgrade your main application to capnp-rpc-unix 2.0. Calls to functions in the
Capnp_rpc_unixandCapnp_rpc_netmodules will need minor updates. They were previously called from Lwt context, so you'll need to wrap them withLwt_eio.run_eio(or remove aLwt_eio.run_lwtif you already updated the surrounding code). Upgrade code and libraries using
Capnp_rpc_lwt:- Replace
open Capnp_rpc_lwtwithopen Capnp_rpc.Std. - Replace all other uses of
Capnp_rpc_lwtwith justCapnp_rpc. - In
duneandopamfiles, replacecapnp-rpc-lwtwithcapnp-rpc. - Some modules are in
Capnp_rpcbut not theCapnp_rpc.Stdsubset. Those should now be fully qualified (e.g. replacePersistencewithCapnp_rpc.Persistence). - Replace
Service.return_lwtwithLwt_eio.run_lwt. ReplaceLwt.return (Ok x)withService.return x.
- Replace
Once all Lwt code is gone, you can remove the dependencies on lwt and lwt_eio.
New features:
- Allow numeric IPv6 listen addresses (@talex5 #296, requested by @BChabanne).
API changes:
Eio port (@talex5 #280 #284 #298 #292 #297 #300 #304).
This switches capnp-rpc from Lwt to Eio. One particularly nice side effect of this is that
Service.return_lwthas gone, as there is no distinction now between concurrent and non-concurrent service methods.Uses of
Capnp_rpc_lwtshould be replaced by uses ofCapnp_rpc(and the oldCapnp_rpcis now an internal module,Capnp_rpc_proto). The newCapnp_rpcnow providesError,ExceptionandDebugaliases to the same modules inCapnp_rpc_proto, so thatCapnp_rpc_protodoesn't need to be used directly.Capnp_rpc_lwtnow provides (deprecated) compatibility wrappers, usinglwt_eio.This also adds
Capnp_rpc.Stdwith some common module aliases, to reduce the need toopen Capnp_rpc(which is rather large).- Deprecate
Debug.failf(@talex5 #291).
Performance and bug fixes:
- Add buffering of outgoing messages (@talex5 #287 #303). Sending each message in its own TCP packet isn't very efficient, and also interacts very badly with Nagle's algorithm. See https://roscidus.com/blog/blog/2024/07/22/performance/ for details.
- Only disconnect socket when sending is done (@talex5 #295). Allows sending the reason for the disconnection in some cases.
- Fix type of
Capability.call(@talex5 #293). It was previously unusable. - Work around FreeBSD
closeproblem (@talex5 #302).
Build:
- Update to capnp 3.6.0 (@talex5 #285).
- Update to dune 3.16 and fix warnings (@talex5 #282).
- Use
String.starts_withinstead ofAstring(@talex5 #290). - Remove unused
tls-miragedependency (@talex5 #289). - Remove
asetmapdependency (@talex5 #288).
v1.2.4
Update dependencies and remove capnp-rpc-mirage (@talex5 #276).
- Update for breaking changes in tls, mirage-crypto and mirage-flow.
- capnp-rpc-mirage isn't used much, and won't be needed after switching to Eio.
- Update tests to Cap'n Proto 1.0.1 (@MisterDA #274).
- Update links to ocaml-ci and capnp-ocaml (@tmcgilchrist #271).
- Opam doesn't allow with-test in conflicts (@talex5 #269).
- Disable opam tests on macos (@talex5 #268).
- Update CI (@MisterDA #272, @talex5 #277).
v1.2.3
- Update to cmdliner 1.1.0 (@MisterDA #249).
- Fix tests on Windows, avoid using Unix domain sockets (@talex5 #251).
- Fix warning on
Unix.ENOTCONNunder macos (@talex5 #252). - Add
Capnp_rpc_unix.Cap_file.save_uri(@talex5 #253). - Update README to use MDX (@talex5 #254).
- Update tests to Cap'n Proto 0.10.3 (@MisterDA #257 #260).
- Update to mirage-crypto-rng 0.11 and dns 7.0.0 API changes (@hannesm #261).
- Update for opam 2.1+ installations (@frumioj #259).
- Install Cap'n Proto binaries in Windows GHA (@MisterDA #248).
v1.2.2
- Switch from mirage-{stack,protocols} to tcpip (@MisterDA #246).
- Remove deprecated tcpip.unix dependency (@hannesm #245).
- Add OCaml 4.14 support (@kit-ty-kate #244).
v1.2.1
- Fix Fmt deprecation warnings (@tmcgilchrist #239).
- Update to latest X509 and DNS APIs (@tmcgilchrist #240).
v1.2
- Don't crash if the peer disconnects before the bootstrap reply is ready (@talex5 #234). When replying to a normal question we checked that the answer was still needed before trying to reply, but didn't for bootstrap requests.
- Replace
wait_until_settledwith saferawait_settled(@talex5 #233).wait_until_settledmakes it too easy to ignore errors. - Require fmt >= 0.8.7 for
kstrand set OCaml 4.08 as the minimum version everywhere (@talex5 #232). Older versions aren't tested in CI because the unix and mirage packages require at least OCaml 4.08.
v1.1
- Update to latest X509, TCP and TLS APIs (@talex5 @hannesm #228).
- Add
Service.fail_lwtconvenience function (@talex5 #229). - Remove confusing debug details from
call_for_value_exnerrors (@talex5 #230). The hidden information is now logged (at debug level) instead. - Configure TCP keep-alives for incoming connections, not just outgoing ones (@talex5 #227). This is needed when the client machine crashes without resetting the connection.
- Include version number in opam license field (@talex5 #226).
v1.0
- Skip the setting of
object_idif it is empty (@LasseBlaauwbroek #224). This improves interoperability with the C++ implementation. - Use
open_in_bininstead ofopen_infor Windows compatibility (@MisterDA #222).
v0.9.0
- Add connection progress indicator (@talex5 #220). Clients can now use
Capnp_rpc_unix.with_cap_exnto show a progress indicator while waiting to connect. It will use the log if enabled. If not, but stderr is a tty, it shows a message while connecting and then erases it (if connecting takes longer than 0.5s). If stderr is not a tty, it just prints a message there. - Use
Mirage_crypto_rng_lwt.initializeinstead ofMirage_crypto_rng_unix.initialize(@hannesm #217). The former periodically feeds entropy to the RNG, while the latter seeds the RNG only once. - Set TCP_KEEPIDLE=60 if possible (@talex5 #214). Cap'n Proto connections tend to be long lived and we therefore turn on the
SO_KEEPALIVEoption. However, the default keepalive timeout of 2 hours is much too long for some networks. In particular, Docker's libnetwork silently drops idle connections after about 10 minutes.
Windows support:
- Prevent crash if ExtUnix wasn't built with sockopt (@MisterDA #218). If ExtUnix isn't built with sockopt then the symbol
have_sockopt_intisn't available and an exception is raised. This may be the case on some environments (e.g., ExtUnix built with mingw-w64). It is a workaround until support forTCP_KEEPIDLEis added for these environments (e.g., using Winsock instead). - There is no SIGPIPE on Windows (@dra27 #212).
- Switch from "capnpc" to "capnp compile" (@talex5 #213).
capnpcseems to be the old name, and isn't present on Windows.
Build changes:
- Remove Travis and Dockerfile (@talex5 #220). Travis is very slow and error-prone now, and ocaml-ci generates a working Dockerfile automatically for people who want it.
- Include transitive dependencies in opam files (@talex5 #219). Patch generated by https://github.com/ocurrent/opam-dune-lint/
- Require
tcpip.unixspecifically to get the checksum stubs linked (@hannesm #216).
v0.8.0
Bug fixes and diagnostics:
- Don't GC imports with callbacks (@talex5, #210).
- Improve "Already resolved!" error message (@talex5, #209). Show the state of the promise we were trying to set, and what we tried to set it to.
- Reject attempts to send after disconnecting (@talex5, #208).
- Unix: don't leak FDs if
Network.connectfails (@talex5, #206). Also, useLwtto open connections so we don't block the whole process.
New functions:
- Add
Sturdy_ref.with_capandwith_cap_exnconvenience functions (@talex5, #207). Using the plainconnectfunctions, it's easy to forget to release the live-ref at the end.
Build changes:
- capnp-rpc-mirage: adapt test to tcpip 5.0.0 API (@hannesm, #205).
- Upgrade to dune 2 (@talex5, #204).
- Switch tests to build in native code and use the test stanza (@avsm, #203).
Documentation:
- Show how to make a connection directly (@talex5, #202). The new
test-bin/calc_direct.mlexample shows how a parent process can spawn a child and communicate with it directly over a socketpair.
v0.7.0
- Update for x509 0.11.0 API changes (@talex5, #196).
- Update to new mirage network API (@Cjen1, #198).
- Add echo benchmark test (@Cjen1, #197).
- Estimate message sizes to improve performance (@talex5, #200). By default, capnproto allocates 8k buffers, but most capnp-rpc messages are much smaller than this.
Logging:
- Fix application logging, to use library's log (@Cjen1, #195).
- Expose the endpoint logger (@Cjen1, #195).
- Only enable debug logging for capnp libraries in the calc example. TLS now generates a lot of messages at debug level (@talex5, #200).
v0.6.0
- Port to latest interfaces for x509 (0.10+), mirage-crypto, alcotest (1.0+), and mirage-types post the
-lwtpackage merge (@avsm #190, review by @talex5 @hannesm) - Convert many info-level log messages to debug level (@talex5 #193)
v0.5.0
Breaking changes:
- The networking parts of
capnp-rpc-lwthave been split off into a newcapnp-rpc-netpackage (@talex5, #182). This means that libraries that provide or consume capnp-rpc services can just depend oncapnp-rpc-lwt, without pulling in a full TLS stack. Only applications should need to depend oncapnp-rpc-net(which will probably happen automatically viacapnp-rpc-unixorcapnp-rpc-mirage). If you get compile errors in your code due to this change, you probably just need toopen Capnp_rpc_net.
Other changes:
- Add Prometheus metrics for connections (@talex5, #183).
capnp-rpc-netnow reports the current number of active connections, the total number of messages received, and the total number of messages enqueued, sent and dropped (from which you can work out the current number of queued messages). - Adapt to x509 0.8.x API changes (@hannesm, #176).
- In the tutorial, say where to put the
Callbackmodule (@talex5, #177). - "No client certificate found" should not be fatal (@talex5, #178).
- Remove unused dependency on
mirage-flow-unixfrom opam file (@talex5, #179).
v0.4.0
Breaking changes:
- Wrap errors with the
`Capnptag to make it easier to compose with other types of error (#172, #173). - Prefix all command-line options with
capnp-(#163). e.g.--listen-addressis now--capnp-listen-address. The old names were confusing for applications that supported other protocols too (e.g. a web server).
New features:
- Add
Capability.with_refconvenience function (#170). This automatically callsdec_refwhen done. - Add Unix
Cap_filemodule to load and saveSturdy_refs(#165). In particular, this ensures that saved cap files get a mode of0o600, since they contain secrets. - Export cmdliner network address parsing (#165). This is useful if you don't want to use the default option parsing. For example, if you want to make Cap'n Proto an optional feature of your program.
- Upgrade from
uint(which is deprecated) to the newerstdint(#166, #168). The latest version ofuintis just a wrapper aroundstdint, so this shouldn't break anything if you are using the latest version. - Put cmdliner options in their own man-page section (#163). Use
Capnp_rpc_unix.manpage_capnp_optionsto control where in your man-page they appear. Enable
SO_KEEPALIVEfor TCP connections (#167). For use with Docker's libnetwork, try something like this in yourstack.yml:sysctls: - 'net.ipv4.tcp_keepalive_time=60'
Bug fixes:
- Close listening socket when shutting down a vat (#171).
- Don't mark secret keys as executable (#164).
- Update README example to use dune (#162).
Build changes:
- Replace topkg with dune-release (#169)
- Update opam email address and fix missing bound (#161).
- Update the
dunefiles to allow duniverse / vendored builds (#165). - Fix the crossed-calls unit test (#171).
- Force all capnp-rpc subpackages to have the same version (#173).
v0.3.3
- Update uint.uint32 to uint (@Cjen1, #159).
- Update to new x509 API (@talex5, #158).
- Require base64 >= 3.0.0 for capnp-rpc-mirage too (@talex5, #157).
- Put test sockets in temporary directory (@talex5, #156).
v0.3.2
- Update for various upstream API changes, switch to the opam 2 metadata format, and convert from jbuilder to dune (@talex5, #152).
Adjust to mirage-stack / mirage-protocols changes (Nick Betteridge, #151).
- update mirage/network for upgraded Ipaddr
- update Dockerfile to use opam2, apt-get update, and newer opam-repository
- Update dependencies from opam-repository (@talex5, #148).
0.3.1
- Updates for new
x509API and for OCaml 4.06 (#143). - Add some diagrams to the tutorial (#134).
- Add FAQ: how can I import a sturdy ref that I need to start my vat? (#137)
Build updates:
- Add build dependency on conf-capnproto (#146). Projects using the schema compiler themselves should also now add this dependency instead of relying on
capnpto pull it in. - Remove generics from persistent.capnp (#141) so that it compiles on systems with older capnproto compilers (e.g. Ubuntu 14.04).
unix/network.mlusesFmt.failwith, which requires fmt.0.8.4 (#139).capnp-rpc-lwtrequiresUri.with_userinfo, which is only inuri>= 1.6.0 (#138).- Move test-lwt to unix module (#133).
0.3 Unikernels
This release adds a new capnp-rpc-mirage package, which provides support for using the library within a MirageOS unikernel. See https://github.com/mirage/capnp-rpc#how-can-i-use-this-with-mirage for details.
There are a few minor API changes:
Capnp_rpc_unix.Vat_config.derived_id ?name configis nowCapnp_rpc_unix.Vat_config.derived_id config name. If you weren't passing a~nameargument before, use"main"to get the same ID.Capnp_rpc_unix.Network'sSocket_addressmodule is now calledLocation.- There is an explicit network parameter in
Network.connect, etc. This is needed to support Mirage, where the network isn't a global.
Bug fixes:
- Fix race when reconnecting. We notified the user that the capability had broken while the old connection was still shutting down. If they immediately tried to reconnect, we tried to reuse the old connection. Now, we wait for it to be removed.
- Fix handling of leaks in switchable. If we detected the ref-count was invalid, we tried to resolve to an error, but resolving now checks that the ref-count is valid first so this failed.
Documentation and examples:
- Fixed ref-counting bug in calculator example. Also, changed the service ID to match what the C++ client expects. With these changes, the C++ client's tests pass when used with the OCaml service.
Fuzzing:
- Also test answering questions with errors or with a promise from another question.
Code cleanups:
- Use a better way to get the client certificate from a TLS connection (suggested by @hannesm).
- Use
Alcotest_lwtfor unit-tests. - Move
capnp://URI handling toCapnp_rpc_lwt.Capnp_address. This allows it to be shared with the Mirage code. - Add
Capnp_rpc_lwt.VAT_NETWORKwith simpler signature thanS.VAT_NETWORK. - The address sub-module of
S.NETWORKis now available separately asS.ADDRESS.
0.2 Persistence, encryption and access control
This release brings support for RPC Level 2.
The API for implementing services and clients is mostly unchanged, but the APIs for setting up networking are very different. If you read the tutorial with the 0.1 release, you will probably want to read the new version again from the "Networking" point onwards.
The main change is that when connecting to a service you now give a URI of the form:
capnp://hash:digest@address/service
The client will connect to address, check the server's public key matches hash:digest, and then pass the (secret) service ID to get access to a particular service. The server will typically display the URI to use on start-up, or write it to a file.
The communications are encrypted using TLS. If you want to disable TLS, use the form capnp://insecure@address. This should only be needed for interoperability with non-TLS services, as the system will generate keys and certificates automatically, making secure use just as easy as the non-secure case.
The other major new feature is support for persistent services. In version 0.1 you could specify an offer argument when creating a vat, telling it a service to provide in response to bootstrap requests. Now, you pass a restore argument, which can restore different services depending on the service ID provided by the client.
The new Restorer.Table module provides a table-based lookup restorer, to which services can be added dynamically. If you have a lot of services and don't want to add them all at startup, you can use Restorer.Table.of_loader and provide your own function for loading services.
Other changes
Documentation changes:
- The tutorial has been extended and a FAQ added.
- The recommended layout of protocol files has changed. The
Clientsub-module is gone, andservicebecomeslocal. - The examples now have
.mlifiles and there is a newstore.mlexample demonstrating persistence. The examples have been updated to the new layout convention.
Main API changes:
The
Capnp_rpc_lwt.Capabilitymodule adds some useful functions:brokencreates a broken capability.when_brokenallows you to be notified when a capability breaks (e.g. because of a network failure).wait_until_settledwaits until a promise has resolved, if you don't want to pipeline (e.g. you want to send a large amount of data, so prefer to find out where the service is and avoid any forwarding).equaltests if two capabilities designate the same service.
- The new
Capnp_rpc_lwt.Sturdy_refmodule provides an abstraction for off-line capabilities.Sturdy_ref.connectcan be used to get a live connection. If you try to connect to multiple services in the same vat, it will share a single connection automatically.Sturdy_ref.readerandSturdy_ref.buildercan be used for passing sturdy refs in messages. - The new
Capnp_rpc_lwt.Restorermodule is used to implement sturdy-refs at the hosting side. - The new
Capnp_rpc_lwt.Persistencemodule provides support for the Cap'n Proto persistence protocol. Clients usePersistence.saveto request a sturdy ref from a service, and services can usePersistence.with_sturdy_refto answer such requests automatically. - The new
Capnp_rpc_unix.Vat_configcollects together all vat configuration in one place. - The new
Capnp_rpc_unix.File_storecan store Cap'n Proto structs in a directory. It can be useful when implementing persistence. - The new
Capnp_rpc_lwt.Authmodule provides support for generating and handling secret keys and fingerprints. - The new
Capnp_rpc_lwt.Tls_wrapperprovides support for doing TLS handshakes, with authentication and encryption.
In the core capnp-rpc package (which applications do not normally use directly):
- The new
cap#when_releasedmethod can be used to find out when a capability is no longer needed. The restorer uses this to remove dynamically loaded services from its table automatically. - The new
when_brokenhelper adds a callback to call when a promise or far-ref becomes broken. NETWORK_TYPESis now separate fromCORE_TYPES.
0.1
- Initial release. RPC Level 1 is fully implemented.