Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Away From Internal Executor #2

Open
zicklag opened this issue Mar 31, 2020 · 4 comments
Open

Migrate Away From Internal Executor #2

zicklag opened this issue Mar 31, 2020 · 4 comments
Assignees

Comments

@zicklag
Copy link
Member

zicklag commented Mar 31, 2020

We want to use Agnostik for the executor instead of maintaining our own.

@Stupremee
Copy link

Hey 👋
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.

@zicklag zicklag changed the title Migrate Executor to Agnostik Migrate Away From Internal Executor Apr 28, 2020
@zicklag
Copy link
Member Author

zicklag commented Apr 28, 2020

Hey there, thanks for the note. 😃 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.

@zicklag
Copy link
Member Author

zicklag commented Apr 28, 2020

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(())
    })
}

@Stupremee
Copy link

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.

@zicklag zicklag self-assigned this Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants