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

Move to tokio 0.2 and futures 3 and make groups api async #81

Merged
merged 10 commits into from
Nov 27, 2019

Conversation

coltfred
Copy link
Member

@coltfred coltfred commented Nov 26, 2019

  • Remove futures 0.1 dependency
  • Upgrade to tokio 0.2
  • Change group apis to be async/await
  • Temp fix for over encoding in reqwest for signing

TODO

  • Fix test
  • Figure out if we can be ok with url and signed url being different.

@coltfred coltfred changed the title Move to tokio 0.2 and futures 3 Move to tokio 0.2 and futures 3 and make groups api async Nov 26, 2019
use percent_encoding::SIMPLE_ENCODE_SET;
use reqwest::{
header::HeaderMap,
r#async::{Client as RClient, Request as ARequest},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
r#async::{Client as RClient, Request as ARequest},
r#async::{Client as RClient, Request},

Can this just be Request now, or something more specific like Reqwest if the intent is to differentiate it from IronCoreRequest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should just leave it as Request. ARequest actually came in when we were also using the blocking (then default) Request as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

src/internal/rest.rs Outdated Show resolved Hide resolved
src/internal/rest.rs Outdated Show resolved Hide resolved
src/internal/rest.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@clintfred clintfred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the user and document PRs, I was able to get rid of most (all?) explicit lifetimes as they were mostly needed to make impl/dyn Future happy. I think a similar cleanup can be done here.

Cargo.toml Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
use percent_encoding::SIMPLE_ENCODE_SET;
use reqwest::{
header::HeaderMap,
r#async::{Client as RClient, Request as ARequest},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure the async module is deprecated... maybe? Also there are two reqwest use blocks here. They should probably be combined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

src/internal/rest.rs Show resolved Hide resolved
let parsed_url = Url::parse(encoded_full_url)?;
let query_str_format = |q: &str| format!("?{}", q);
let query_str_format = |q: &str| format!("?{}", q.replace("%27", "'"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should probably be a comment here explaining what's going on here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

src/internal/rest.rs Outdated Show resolved Hide resolved
.map(|sig_url| auth_b.finish_with(sig_url, req.method().clone(), Some(&body_bytes)))
.map_err(|e| IronOxideErr::from((e, error_code)));

// we only support Authorization::Version2 with this call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was some hope that the duplicated code between here and post_raw might be able to be easily refactored once we got rid of v1 futures. Is that worth taking a pass at, do you think?

@@ -1338,7 +1332,7 @@ mod tests {
maybe_path.unwrap().signature_string(),
"/api/1/users?id=user-10"
);

//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

@clintfred
Copy link
Contributor

You should also write the change log entry for moving to futures 3, async/await, and tokio 0.2

src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Outdated Show resolved Hide resolved
src/internal/group_api/mod.rs Show resolved Hide resolved
src/internal/rest.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@clintfred clintfred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but don't forget a CHANGELOG entry.

header::HeaderMap,
r#async::{Client as RClient, Request as ARequest},
header::{HeaderMap, HeaderValue, CONTENT_TYPE},
r#async::{Client as RClient, Request as ARequest, RequestBuilder},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you figure out that the async namespace is still the preferred way to import here?
https:/seanmonstar/reqwest/blob/80ba8cc15066c2a6d35d68b058e795be5e01cd94/src/lib.rs#L301 makes me think otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I just pushed the fix.

@@ -186,6 +184,8 @@ pub struct SignatureUrlString(String);
impl SignatureUrlString {
pub fn new(encoded_full_url: &str) -> Result<SignatureUrlString, url::ParseError> {
let parsed_url = Url::parse(encoded_full_url)?;
//The formatter for the query string is overfomatting compared to what we want, so we want to replace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is worth opening an issue on reqwest? Something like "Support configurable query string encoding". Perhaps if we reference our issue someone will point out a better way all together?

@coltfred coltfred merged commit 0e340cd into master Nov 27, 2019
@coltfred coltfred deleted the group-async branch November 27, 2019 17:58
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.

4 participants