Migrate Away From Internal Executor
Hey :wave: Agnostik maintainer here. Agnostik should already be fully usable in its current state and can be implemented without problems. If there are problems, I'm always ready to help with the solution.
Hey there, thanks for the note. :smiley: I'll let you know if I have any trouble. I just took a look at the source code for Agnostik which is very simple and short, which is nice.
Interesting timing, though, because I just found smol this morning and it looks like it might be a good fit and compatible Tokio and async-std. I might end up just using smol or maybe, because it look so easy, add a smol backend to Agnostik.
I'll look into them both a bit more when I get down to actually working on it and any progress/decisions I make will be posted here.
I'm leaning towards smol at the moment because of its ability to support multiple runtimes at the same time. That's pretty awesome. It would mean that people could come to maxim and be able to run pretty much any async library with it, even multiples with different runtimes.
https://github.com/stjepang/smol/blob/master/examples/other-runtimes.rs
fn main() -> Result<()> {
smol::run(async {
// Sleep using async-std.
let start = Instant::now();
println!("Sleeping using async-std...");
async_std::task::sleep(Duration::from_secs(1)).await;
println!("Woke up after {:?}", start.elapsed());
// Sleep using tokio (the `tokio02` feature must be enabled).
let start = Instant::now();
println!("Sleeping using tokio...");
tokio::time::delay_for(Duration::from_secs(1)).await;
println!("Woke up after {:?}", start.elapsed());
// Make a GET request using surf.
let body = surf::get("https://www.rust-lang.org")
.recv_string()
.await
.map_err(Error::msg)?;
println!("Body from surf: {:?}", body);
// Make a GET request using reqwest (the `tokio02` feature must be enabled).
let resp = reqwest::get("https://www.rust-lang.org").await?;
let body = resp.text().await?;
println!("Body from reqwest: {:?}", body);
Ok(())
})
}
I will add smol support to agnostik very soon. In the Next Agnostik you will also be able to implement your own executors so it’s super simple to add a new executor backend.