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

Go async #730

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft

Go async #730

wants to merge 46 commits into from

Conversation

igalic
Copy link
Contributor

@igalic igalic commented Jan 22, 2020

update rocket and its dependencies to their async branch.
update our code to use rocket's async APIs

@codecov
Copy link

codecov bot commented Jan 22, 2020

Codecov Report

Merging #730 into main will increase coverage by 0.16%.
The diff coverage is 100.00%.

@@            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     

@igalic igalic force-pushed the go/async branch 2 times, most recently from b56ad50 to 2ba0cf2 Compare February 17, 2020 22:34
}
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)?;
Copy link
Contributor Author

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.

Copy link
Member

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?

igalic and others added 25 commits May 6, 2020 21:01
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)
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
igalic added 3 commits May 6, 2020 22:30
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)>
```
igalic added 18 commits May 15, 2020 22:38
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].
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
@elegaanz elegaanz changed the base branch from master to main July 5, 2020 16:20
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

Successfully merging this pull request may close these issues.

3 participants