Skip to content

Replace async_trait with native async fns#230

Merged
djc merged 3 commits into
djc:mainfrom
gahag-cw:feat/remove-async-trait
Dec 6, 2024
Merged

Replace async_trait with native async fns#230
djc merged 3 commits into
djc:mainfrom
gahag-cw:feat/remove-async-trait

Conversation

@gahag-cw

@gahag-cw gahag-cw commented Dec 3, 2024

Copy link
Copy Markdown
Contributor

Note that the usage of CustomizeConnection requires it to be object safe, and thus we need to use boxed futures instead of plain async fns.

@gahag-cw

gahag-cw commented Dec 3, 2024

Copy link
Copy Markdown
Contributor Author

@djc we have an issue with the coverage pipeline:

There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 429 - {"message":"Rate limit reached. Please upload with the Codecov repository upload token to resolve issue. Expected time to availability: 2144s."}

@djc djc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This mostly looks good to me. Please squash into two commits:

  1. MSRV bump
  2. All the code changes

Comment thread bb8/src/api.rs Outdated
/// error, it will be forwarded to the configured error sink.
async fn on_acquire(&self, _connection: &mut C) -> Result<(), E> {
Ok(())
fn on_acquire<'a, 'b, 'r>(&'a self, _connection: &'b mut C) -> BoxFuture<'r, Result<(), E>>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can we spell this <'r, 'a: 'r, 'b: 'r> instead? And do we really need the 3 separate lifetimes?

Why is BoxFuture useful? Could we just do Box<dyn Future<..>> instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BoxFuture<'a, T> is actually Pin<Box<dyn Future<Output = T> + Send + 'a>>. I'll apply the suggestions.

@gahag-cw gahag-cw Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And do we really need the 3 separate lifetimes?

I'm not sure, but that's what async_trait generated, so I kept it to prevent further breaking changes in the API.

@djc

djc commented Dec 6, 2024

Copy link
Copy Markdown
Owner

I think #231 has solved the coverage issue, please rebase on top of current main.

@gahag-cw

gahag-cw commented Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

@djc I applied the following suggested changes:

  • squash into MSRV bump and code changes commits
  • change on_acquire lifetimes to <'r, 'a: 'r, 'b: 'r>
  • replace all usages of BoxFuture<'r, Result<(), Error>> with Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'r>>

Let me know if you have any further suggestions.

Comment thread bb8/src/api.rs Outdated
@djc

djc commented Dec 6, 2024

Copy link
Copy Markdown
Owner

Please also add a separate commit that bumps all the version numbers.

@gahag-cw

gahag-cw commented Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

@djc done.

@djc djc merged commit 6e2a586 into djc:main Dec 6, 2024
@djc

djc commented Dec 6, 2024

Copy link
Copy Markdown
Owner

Thanks!

@djc

djc commented Dec 9, 2024

Copy link
Copy Markdown
Owner
  • Published bb8 v0.9.0 at registry crates-io
  • Published bb8-postgres v0.9.0 at registry crates-io
  • Published bb8-redis v0.18.0 at registry crates-io
  • [new tag] v0.9.0 -> v0.9.0
  • Release notes

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.

2 participants