CHANGES:
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 toLwt_main.run
with code to run Eio and Lwt together,
as explained at the start of thelwt_eio
README. -
Upgrade your main application to capnp-rpc-unix 2.0.
Calls to functions in theCapnp_rpc_unix
andCapnp_rpc_net
modules 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_lwt
if you already updated the surrounding code).
You should also usemirage-crypto-rng-eio
to ensure randomness is available
(capnp-rpc-unix
no longer does this, although some other library might). -
Upgrade code and libraries using
Capnp_rpc_lwt
:- Replace
open Capnp_rpc_lwt
withopen Capnp_rpc.Std
. - Replace all other uses of
Capnp_rpc_lwt
with justCapnp_rpc
. - In
dune
andopam
files, replacecapnp-rpc-lwt
withcapnp-rpc
. - Some modules are in
Capnp_rpc
but not theCapnp_rpc.Std
subset.
Those should now be fully qualified (e.g. replacePersistence
with
Capnp_rpc.Persistence
). - Replace
Service.return_lwt
withLwt_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 thatService.return_lwt
has gone,
as there is no distinction now between concurrent and non-concurrent service methods.Uses of
Capnp_rpc_lwt
should be replaced by uses ofCapnp_rpc
(and the oldCapnp_rpc
is now an internal module,Capnp_rpc_proto
).
The newCapnp_rpc
now providesError
,Exception
andDebug
aliases to the same modules inCapnp_rpc_proto
,
so thatCapnp_rpc_proto
doesn't need to be used directly.Capnp_rpc_lwt
now provides (deprecated) compatibility wrappers, usinglwt_eio
.This also adds
Capnp_rpc.Std
with some common module aliases,
to reduce the need toopen Capnp_rpc
(which is rather large).
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.
Build: