-
Notifications
You must be signed in to change notification settings - Fork 117
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
Add support for std::future and async/await #71
Conversation
Will also need someone with access to a Windows machine to port https://github.com/nikvolf/tokio-named-pipes. Shouldn't be too hard I think. |
Currently seemingly stuck on rust-lang/rust#46415 (comment) -- the compiler runs out of stack when trying to compile the code, presumably due to a cyclic |
I think in theory we could also improve some of the APIs a fair amount as part of this process. For example, we no longer really need to have all the futures return |
It's a lot of work, thanks!
I've downloaded a fresh image from https://developer.microsoft.com/en-us/windows/downloads/virtual-machines a week ago, but I'm not sure on how soon i would be able to work on this. I need to close some education-related stuff during this weekend because of a deadline. |
@blackbeam I actually reached out to @NikVolf (the maintainer) and got a reply saying they'd take a look! |
Thanks for your work! Looking forward to finally ditching futures 0.1 (this is my last dependency using it)! |
Tests now pass on CircleCI (though they require nightly of course) 🎉 Windows won't work until we have Also, @blackbeam, how would you feel about moving to Azure Pipelines using https://github.com/crate-ci/azure-pipelines ? It's pretty easy to set up, and would mean we don't have to have two configs that have tons of random command strings everywhere. |
@jonhoo I've looked into porting |
@PvdBerg1998 Ah interesting.. Trying that now. |
Oh, that's awkward. What is it that fails? Presumably cargo should just compile both versions? |
Yeah I've been trying to patch it but it's being difficult for some reason. The error is:
I tried patching it using |
@taiki-e Can you shed some light on the issue above? |
Ok so I just got cargo to panic 😅 . Edit: see rust-lang/cargo#7346 |
This is because pin-project is still alpha, so hyper is pinning that version. I think it needs to update version of pin-project in hyper and add the following block to Cargo.toml: [patch.crates-io]
hyper = { git = "https://github.com/hyperium/hyper", version = "0.13.0-alpha.1" } |
@jonhoo I forked
Edit: you have that bound there though... I'm confused |
I forked the PR and removed the |
Other functionality seems to work 🎉 |
@blackbeam what do you think still remains for this? |
@jonhoo, patch section should be removed from Cargo.toml. But at the moment this won't work, because tokio-rs/tokio#1537 not yet published. |
How hard it would be to make all the methods taking self by value to make them to be by reference? Right now abstracting mysql to a more generic database crate is not that easy due to other crates just using references. At least tokio-postgres uses an approach where you have a |
@pimeys so, I took a quick look at that when I did this PR, and while in theory it shouldn't be too bad, in practice a tonne of the code relies on being able to move in and out of things. This is (as you probably guessed) because much of the state keeping for each connection is done inside the |
@pimeys, that's interesting. Looks like major change to the current architecture. I'm not sure, however, about pros of this approach except API convenience. |
@blackbeam It does make the API much nicer to use, because you no longer need to "chain along" let result = c.query("...").await?;
let (c, rows) = result.collect_and_drop().await?;
let c = c.drop_query("...").await?; instead you can just write code without moving let rows = c.query("...").await?.collect_and_drop().await?;
c.drop_query("...").await?; |
@jonhoo, agree with that. I believe it worth, at least, to try to implement it to measure the consequences. |
We here at Prisma are abstracting the databases (psql, mysql, sqlite) under our own connector crate, and right now with the sync crates the generic connector is very easy to do. Not that much when we switch to async execution, due to mysql being completely different than the others. I've been reading the tokio-postgres code a lot and they seem to have a nice way of making it to work: What makes their way even sweeter the way the transactions can be rolled back in Now your transaction can work like the sync counterpart. If you error out, RAII takes care of the rollback. |
@pimeys, btw, |
Published as v0.21.0-alpha.1 |
New non-consuming API is available in v0.24.0-alpha. Could you, please, test it? (api docs) |
I haven't tried very hard, but trying to use 0.24.0 alpha in quaint (prisma/quaint#117), we get a compile error from one of the dependecies:
(it's one of mysql_common's dependencies). |
@tomhoule, it looks like this issue. I believe |
Still a work in progress.
This is a very direct port of the existing codebase. I'm avoiding rearchitecting as much as I can, and instead doing a mostly mechanical transformation. Seems to be going okay so far, but I'm not quite done yet (need tokio-rs/tokio#1537 for example). There are definitely a bunch of places the codebase could be improved (in particular, a bunch of
Box
es that could be removed), but at least this will get us off the ground.Fixes #63.