|
|
|
|
|
by rizzaxc
1572 days ago
|
|
for request schema, do you know how rust/ actix supports protobuf? I find protobuf great for rapid prototyping, and using monorepo for both frontend + backend makes it even better for api consistency. my search shows there are 2 major libraries but the de factor parsing library doesn't support it (Serde) also, I'm interested in how you structure your code. is everything a crate? or you work in a giant namespace with different structs (sorry if this doesn't make sense I don't know much rust) |
|
> for request schema, do you know how rust/ actix supports protobuf?
That's a great question! The serde annotations make it look like it should work. If not, there might be a plugin for it. Actix has a rather vibrant ecosystem of utility crates.
I've used Prost for protos once before (it felt like the more mature option), and the build integration was seamless. I was frustrated with how the IDE handled it at the time (Clion+Rust), which is one of the reasons I'm not using protos in Rust today. The IDE couldn't work out the types and everything touching the syntax tree near protos was opaque to the IDE. It was over two years ago the last time I checked the status of protos in Rust, so there's a good chance the situation has improved.
I didn't use Prost with Actix in particular, which is why I can't really provide insight there. It should be quick to set up a test.
I'm using two monorepos: one for frontend (yarn/typescript/react for three websites) and one for backend (all Rust; two servers and seven jobs). If I'd lumped it all together, I would have investigated protos more seriously. I should probably investigate using them again in the near future.
> also, I'm interested in how you structure your code. is everything a crate?
I'm using Rust workspaces to organize the backend monorep. I have about ten binaries, and five library crates that are shared between the various binaries. I also have a few vendored packages that aren't available on crates.io (newrelic-telemetry-sdk, etc.) I was told Bazel does a good job with build caching, so I'll investigate using that soon so I'm not always rebuilding the world.
> or you work in a giant namespace with different structs (sorry if this doesn't make sense I don't know much rust)
With the way modules work, there's next to no need for that in Rust. It's one of the most hygienic import systems I've used.
Overall, I'm extremely happy with the setup and it's been really productive for me.