capnproto / capnproto-rust

Cap'n Proto for Rust
MIT License
2.04k stars 221 forks source link

How to check schema compatibility? #415

Open erenon opened 1 year ago

erenon commented 1 year ago

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!

dwrensha commented 1 year ago

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.

erenon commented 1 year ago

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)