-
Notifications
You must be signed in to change notification settings - Fork 138
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
Go async #730
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #730 +/- ##
==========================================
+ Coverage 38.95% 39.11% +0.16%
==========================================
Files 73 73
Lines 9729 9643 -86
Branches 2227 2183 -44
==========================================
- Hits 3790 3772 -18
+ Misses 4885 4819 -66
+ Partials 1054 1052 -2 |
b56ad50
to
2ba0cf2
Compare
src/routes/mod.rs
Outdated
} | ||
fn respond_to(self, r: &'r Request<'_>) -> response::ResultFuture<'r> { | ||
Box::pin(async move { | ||
let contents = std::fs::read(self.0.path()).map_err(|_| Status::InternalServerError)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this std::fs::read could (should?) be async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could with something like async-std, yes. But maybe add a todo and leave it for a future PR?
and run cargo update
it only took 3 hours of @jebrosen's patient help.
n.b.: I do *not* like the error handling in api_tokens 😒️
there doesn't seem to be a request.guard_async (yet?)
where sensible! note that State has no asynchronous work to do, so wrapping it up in async makes no sense.
i'm using this opportunity to also update reqwest (0.10), but it's turning out to be a little trickier, as it requires more modern async setup, and that appears to need a lot of thinking…
defer, or, trait functions such as it in general(?) cannot be async (yet)
including the use of tokio!
this allows us to actually move stuff into the async block and we can drop the 'static life-time.
this way, we only spawn one, and reuse that.
template utils and error routes
as requested in Plume-org/webfinger#8 and provided in Plume-org/webfinger#9 ``` meena@76ix ~/s/a/plume (go/async) [101]> cargo update --package webfinger Updating crates.io index Updating git repository `https://github.com/Plume-org/webfinger` Removing bytes v0.4.12 Removing cookie v0.12.0 Removing cookie_store v0.7.0 Removing crossbeam-deque v0.7.2 Removing crossbeam-epoch v0.8.0 Removing crossbeam-queue v0.1.2 Removing crossbeam-utils v0.7.0 Removing h2 v0.1.26 Removing http v0.1.21 Removing http-body v0.1.0 Removing hyper v0.12.35 Removing hyper-tls v0.3.2 Removing publicsuffix v1.5.4 Removing reqwest v0.9.24 Removing serde_urlencoded v0.5.5 Removing string v0.2.1 Removing tokio v0.1.22 Removing tokio-buf v0.1.1 Removing tokio-current-thread v0.1.6 Removing tokio-executor v0.1.9 Removing tokio-io v0.1.12 Removing tokio-reactor v0.1.11 Removing tokio-sync v0.1.7 Removing tokio-tcp v0.1.3 Removing tokio-threadpool v0.1.17 Removing tokio-timer v0.2.12 Removing try_from v0.3.2 Removing want v0.2.0 Adding webfinger v0.5.0 (https://github.com/Plume-org/webfinger?rev=update-deps#cdaab95e) Removing webfinger v0.5.0 meena@76ix ~/s/a/plume (go/async)> ```
this also upgrades some dependencies some of that fixes stuff, others breaks stuff.
i forgot that we can't `Send` diesel connections over threads, so this is going to require some rethinking.
that our Connection is not Send-safe. once we get there, we can start thinking about restructing the way we pass along our connection, or consider using #[database].
…on is not Send-safe.
that our Connection is not Send-safe.
so we can .await without worries. plus, it changes nothing about the code, other than making the intent clearer at first sight.
not happy about this lint or rust behaviour where the return statement must not have a `;`
we do this by making the macro parse and generate doc comments
update rocket and its dependencies to their
async
branch.update our code to use rocket's async APIs