deepgram-rust-sdk icon indicating copy to clipboard operation
deepgram-rust-sdk copied to clipboard

Proposal: make tokio optional

Open cardoso opened this issue 2 years ago • 7 comments

It should be possible to use the library without picking a runtime.

The live feature would take some work to uncouple from tokio and tungstenite, so I left it under a default flag for now.

cardoso avatar Aug 16 '23 16:08 cardoso

Thanks for the PR!

In principle, I'm okay with the idea of being able to use any runtime. However, our dependency on tokio runs a little deeper than the explicit dependency. reqwest only works with tokio, and we use reqwest to make the HTTP request.

Are you using async-std?

andrewhalle avatar Aug 18 '23 15:08 andrewhalle

@andrewhalle Im using smol and it's possible to use reqwest with a different runtime using the async-compat crate: https://github.com/smol-rs/async-compat

cardoso avatar Aug 18 '23 20:08 cardoso

@cardoso Ah okay, I understand now, thanks! Just to confirm, you're compiling for a WASM target? Otherwise, reqwest is still pulling in the tokio dependency.

andrewhalle avatar Aug 18 '23 21:08 andrewhalle

I see that async-compat has a tokio dependency as well, so even if we make tokio optional in this crate, you'll still be getting it from that, right?

andrewhalle avatar Aug 18 '23 21:08 andrewhalle

@andrewhalle yes, but not the runtime, so it's good enough for now to make the SDK usable with other runtimes and in wasm targets.

It would be good to make reqwest optional as well in the future, so an async runtime wouldn't be needed to access the pre-recorded API, but I wanted to make this PR short.

cardoso avatar Aug 19 '23 23:08 cardoso

Cool, sounds good then. I'll give this a review, and we'll get this in. Thanks!

andrewhalle avatar Aug 21 '23 14:08 andrewhalle

@cardoso Just checking back in on this, is this still something you're interested in merging?

andrewhalle avatar Nov 01 '23 15:11 andrewhalle