benbrittain / rust-xdr

Generate Rust services from XDR RPC
https://tech.okcupid.com/rust-and-rpc-okcupid-hackweek-2017/
MIT License
29 stars 2 forks source link

Upgrade to newer Rust? #1

Open calderonth opened 4 years ago

calderonth commented 4 years ago

Hi there,

I have been trying to use this PoC code to generate some functioning code but since the blog post was written in 2017 most of the Rust ecosystem has changed and libraries it relied have evolved significantly (futures/tokio). So nothing works with an up to date Rust.

I am wondering what it would take to port some of the code to the newer APIs as I am interested in using Rust for a PoC with XDR RPC.

Thanks!

Thomas

benbrittain commented 4 years ago

Hey Thomas!

oof, yeah this code was very wrapped up in the futures 0.1 ecosystem which I would certainly not recommend using anymore. IIRC the serde version used here is also ancient.

It's been a while since I've thought about this code. I'll take a look at it, but I'm guessing that it's pretty non-trivial to upgrade. It'd be kinda fun though :)

benbrittain commented 4 years ago

it looks like this https://docs.rs/serde-xdr/0.5.1/serde_xdr/ is a replacement for half of this repo. (I can't attest to it's quality yet though)

and the other half is the codegen, which should actually be much easier than it was in 2017

calderonth commented 4 years ago

Thanks for the reply, I'm starting with Rust but am keen to have some sort of basic plumbing working the same way you did the previous PoC.

I'm thinking of skipping the codegen part for now and get a really basic service working with the newer serde_xdr library and see how it fits in the new asyn/await paradigm. However, I'm still new to Rust and the new async/await paradigm, so might take me a while.

benbrittain commented 4 years ago

serde_xdr is unaware of the async/await paradigm, it'll just be (de)serialization logic. You'll want to tie it to something like smol or another async executor.

Here is a good example of using that: https://github.com/stjepang/smol/blob/master/examples/simple-client.rs

Also, don't feel pressure to use any of the async/await stuff! Often a threadpool and traditional blocking IO is more than sufficient.

calderonth commented 4 years ago

So serde_xdr is used by https://github.com/jvff/onc-rpc/ it doesn't really do the codegen part as it's more manual but I've managed to compile a basic version. However, it's also relying on some of those old libraries that are now deprecated.