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 async #31

Closed
wants to merge 26 commits into from
Closed

Move to async #31

wants to merge 26 commits into from

Conversation

mkawalec
Copy link
Contributor

I needed to use this library from an async context, decided to move it all the way to async-only after experimenting with having sync/async behind feature flags.

Let me know what you think about this approach @davidgraeff, the tests and Rocket-specific code still need to be ported to async.

When downloading google JWKS, I parse the Cache-Control header to know how long the keys are valid for and download new JWKS if the keys have expired. We are using this library with long running server processes and Google tends to rotate these keys every so often causing rare token validation failures.

async is infectious so it leaks out here and there, but I was mostly guided by the speed of getting this port out of the door to unblock some async contexts in our codebase.

@redvg
Copy link

redvg commented Mar 21, 2022

what needs to happen for this to go upstream?

@JadedEvan
Copy link
Collaborator

Hey @mkawalec - thanks for putting this PR together. A lot of things needed to be updated to accomplish the move to async but I think this represents a very strong body of work. I have a few suggestions for this

  • This is currently failing the CI checks because of non-signed commits. Can you address this in the instructions provided in the failing checks?
  • I would consider squashing your changes into a few meaningful commits. Although this is not a widely trafficked library, it would be nice to have a meaningful and organized git history
  • Usage of conventional commits in the commit messages. While there is not currently a CONTRIBUTING.md attached to this repo - there is quite a fair amount of usage in the current git history.

I would like to spend some more time doing further review for the more complicated changes presented

@@ -21,7 +23,7 @@ struct DemoDTOPartial {
an_int: u32,
}

fn write_document(session: &mut ServiceSession, doc_id: &str) -> errors::Result<WriteResult> {
async fn write_document(session: &mut ServiceSession, doc_id: &str) -> errors::Result<WriteResult> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally the question to ask here in the examples is if we want to convert all of the examples to async code. I don't think the lib should imply that you must use async (though I think most people would indeed chose to do so).

Personally I would choose to move forward with the async approach through these examples. Curious if you have any thoughts @davidgraeff ?

@@ -42,7 +55,7 @@ pub struct Credentials {
pub client_id: String,
pub api_key: String,
#[serde(default, skip)]
pub(crate) keys: Keys,
pub(crate) keys: Arc<RwLock<Keys>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiousity - what is the motivation for Arc<RwLock> on Keys?

@@ -1,6 +1,6 @@
[package]
name = "firestore-db-and-auth"
version = "0.6.1"
version = "0.8.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would argue this should probably be a major version breaking change. With the changes proposed here all sync code disappears - meaning this library becomes exclusively async. Changes here would no longer be compatible with those using the sync only version of this library

@davidgraeff
Copy link
Owner

Thanks a lot for the contribution, thanks @JadedEvan for the review. Async support has been merged with #34. I have taken your pull request as base and added the missing parts. This crate is async only now.

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