capnproto-rust icon indicating copy to clipboard operation
capnproto-rust copied to clipboard

How to check schema compatibility?

Open erenon opened this issue 2 years ago • 2 comments

Thanks for the nice library!

I have a bunch of co-operating, separately deployed rust services, that communicate using capnproto. Servers advertise the schema they are using to publish data. When a client connects to a server, I'd like to make sure that the schema used by the client is compatible with the schema used by the server. Compatible, as in https://capnproto.org/language.html#evolving-your-protocol How can I do that with this library? (I found schema loader in the C++ project, but couldn't connect that component to any piece in the rust lib) Thanks!

erenon avatar Jun 13 '23 08:06 erenon

capnproto-rust currently does not support loading new schemas at run time.

If you don't need to actually transmit the schemas, and you only want to check compatibility, then I expect that you should be able to set up some coordination by transmitting a type ID plus maybe some additional revision number.

dwrensha avatar Jun 13 '23 11:06 dwrensha

Unfortunately, type ID is not enough to check compatibility (or even equivalence), as it only depends on the parent scopes id and the name of the struct (for structs), so if someone e.g: changes a string field to an integer field, the type id will remain the same. (Yes, I'd like to protect against silly changes)

erenon avatar Jun 13 '23 12:06 erenon