#11 Feature: async trait

Merged
igalic merged 8 commits from plume/webfinger:feat/async-trait into main 11 months ago
igalic commented 11 months ago (Migrated from github.com)

add a feature (behind a off-by-default flag) to use async trait implementations.

add a feature (behind a off-by-default flag) to use async trait implementations.
igalic commented 11 months ago (Migrated from github.com)
Owner

for now, this doesn’t work, because impl String is not (necessarily) Send safe.

for now, this doesn't work, because `impl String` is not (necessarily) `Send` safe.
igalic commented 11 months ago (Migrated from github.com)
Owner

current status:

meena@76ix ~/s/a/webfinger (feat/async-trait)> cargo +nightly build --features async
   Compiling webfinger v0.5.0 (/home/meena/src/ap/webfinger)
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
 --> src/async_trait.rs:8:1
  |
8 | #[async_trait]
  | ^^^^^^^^^^^^^^ explicit generic argument not allowed
  |
  = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

error: could not compile `webfinger`.

To learn more, run the command again with --verbose.
meena@76ix ~/s/a/webfinger (feat/async-trait) [101]> 
current status: ``` meena@76ix ~/s/a/webfinger (feat/async-trait)> cargo +nightly build --features async Compiling webfinger v0.5.0 (/home/meena/src/ap/webfinger) error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position --> src/async_trait.rs:8:1 | 8 | #[async_trait] | ^^^^^^^^^^^^^^ explicit generic argument not allowed | = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error error: could not compile `webfinger`. To learn more, run the command again with --verbose. meena@76ix ~/s/a/webfinger (feat/async-trait) [101]> ```
codecov[bot] commented 11 months ago (Migrated from github.com)
Owner

Codecov Report

Merging #11 into main will increase coverage by 2.68%.
The diff coverage is 96.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
+ Coverage   91.39%   94.07%   +2.68%     
==========================================
  Files           2        4       +2     
  Lines         151      287     +136     
==========================================
+ Hits          138      270     +132     
- Misses         13       17       +4     
Impacted Files Coverage Δ
src/lib.rs 86.45% <81.25%> (-1.43%) ⬇️
src/tests.rs 97.54% <98.50%> (+3.42%) ⬆️
src/async_resolver.rs 100.00% <100.00%> (ø)
src/resolver.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c494677...e2b2b37. Read the comment docs.

# [Codecov](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=h1) Report > Merging [#11](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=desc) into [main](https://codecov.io/gh/Plume-org/webfinger/commit/9f1e0e7074d466cf62a618a5c2bb785e50c0c27c&el=desc) will **increase** coverage by `2.68%`. > The diff coverage is `96.39%`. [![Impacted file tree graph](https://codecov.io/gh/Plume-org/webfinger/pull/11/graphs/tree.svg?width=650&height=150&src=pr&token=9gTr9Sg00C)](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=tree) ```diff @@ Coverage Diff @@ ## main #11 +/- ## ========================================== + Coverage 91.39% 94.07% +2.68% ========================================== Files 2 4 +2 Lines 151 287 +136 ========================================== + Hits 138 270 +132 - Misses 13 17 +4 ``` | [Impacted Files](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=tree) | Coverage Δ | | |---|---|---| | [src/lib.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL2xpYi5ycw==) | `86.45% <81.25%> (-1.43%)` | :arrow_down: | | [src/tests.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL3Rlc3RzLnJz) | `97.54% <98.50%> (+3.42%)` | :arrow_up: | | [src/async\_resolver.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL2FzeW5jX3Jlc29sdmVyLnJz) | `100.00% <100.00%> (ø)` | | | [src/resolver.rs](https://codecov.io/gh/Plume-org/webfinger/pull/11/diff?src=pr&el=tree#diff-c3JjL3Jlc29sdmVyLnJz) | `100.00% <100.00%> (ø)` | | ------ [Continue to review full report at Codecov](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=continue). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta) > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=footer). Last update [c494677...e2b2b37](https://codecov.io/gh/Plume-org/webfinger/pull/11?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
igalic commented 11 months ago (Migrated from github.com)
Owner

back to building, now we need to add a test for async.

This: https://gist.github.com/a5727727c2f55be6f37e937bfc232d32 is not it: https://gist.github.com/ae41ec328a2a443fa02214a4b0f19281

back to building, now we need to add a test for async. This: https://gist.github.com/a5727727c2f55be6f37e937bfc232d32 is not it: https://gist.github.com/ae41ec328a2a443fa02214a4b0f19281
trinity-1686a approved these changes 11 months ago
trinity-1686a left a comment

LGTM

I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr

@@ -0,0 +9,4 @@
pub trait AsyncResolver {
type Repo: Send;
/// Returns the domain name of the current instance.
async fn instance_domain<'a>(&self) -> &'a str;
trinity-1686a commented 11 months ago

I’m not sure this requires to be async, I would expect an implementation to return one of its fields, but I guess there is nothing wrong with too much async, it’ll just get optimized away during monomorphisation

I'm not sure this requires to be async, I would expect an implementation to return one of its fields, but I guess there is nothing wrong with too much async, it'll just get optimized away during monomorphisation
igalic (Migrated from github.com) reviewed 11 months ago
@@ -0,0 +9,4 @@
pub trait AsyncResolver {
type Repo: Send;
/// Returns the domain name of the current instance.
async fn instance_domain<'a>(&self) -> &'a str;
kiwii commented 11 months ago

and if it’s async in the trait signature, it means you can use await in the function body.

and if it's `async` in the trait signature, it means you can use `await` in the function body.
igalic commented 11 months ago (Migrated from github.com)
Owner

LGTM

I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr

how do you suggest improving those?
ideally, i’d like to do that before a next release, because, more importantly, i’d like to call the next release ‘1.0’

> LGTM > > I feel like test_my_resolver/test_my_async_resolver are more coverage oriented than correctness : the valid answer is barely validated, however this is unrelated to this pr how do you suggest improving those? ideally, i'd like to do that before a next release, because, more importantly, i'd like to call the next release '1.0'
trinity-1686a commented 11 months ago
Owner

hum, endpoint() rely way more on find() than I though so in fact any incorrectness on a valid answer would come from find(), never mind my comment

hum, endpoint() rely way more on find() than I though so in fact any incorrectness on a valid answer would come from find(), never mind my comment

Reviewers

trinity-1686a approved these changes 11 months ago
The pull request has been merged as 4e8f12810c.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.