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

Remove #[async_trait] where possible #1055

Merged
merged 1 commit into from
Jun 26, 2024
Merged

Remove #[async_trait] where possible #1055

merged 1 commit into from
Jun 26, 2024

Conversation

jhpratt
Copy link
Contributor

@jhpratt jhpratt commented Jun 25, 2024

Description

async fn and -> impl Trait is stable in traits. This uses it wherever possible. Due to trait bound requirements, all converted functions need -> impl Future + Send.

Due to compiler limitations, namely dyn Trait compatibility, it is not possible at this time to convert the remaining uses without creating concrete types and implementing Future by hand.

Fixes #620

Type of change

Code simplification

How Has This Been Tested?

cargo check passes as expected; bazel test //... succeeds as well.

Checklist

  • Updated documentation if needed
  • Tests added/amended
  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

This change is Reviewable

@CLAassistant
Copy link

CLAassistant commented Jun 25, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 13 of 13 files at r1.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable, and 3 discussions need to be resolved


-- commits line 2 at r1:
nit: Please reference ticket in commit.


nativelink-util/src/health_utils.rs line 104 at r1 (raw file):

/// A default implementation is provided for the `check_health` function
/// that returns healthy component.
#[async_trait] // FIXME remove this if/when traits containing async fn can be used as trait objects

nit: This comment doesn't have any value. There's no timeline on when/if they will ever do this, so lets just keep using it as is without a comment.


nativelink-util/src/store_trait.rs line 153 at r1 (raw file):

/// A key that has been subscribed to in the store. This can be used
/// to wait for changes to the data for the key.
#[async_trait] // FIXME remove this if/when traits containing async fn can be used as trait objects

ditto.

Copy link
Collaborator

@MarcusSorealheis MarcusSorealheis left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

Reviewable status: 2 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Installation / macos-13, Installation / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), macos-13, windows-2022 / stable, and 3 discussions need to be resolved

Copy link
Contributor Author

@jhpratt jhpratt left a comment

Choose a reason for hiding this comment

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

I've made the requested changes.

Reviewable status: 2 of 1 LGTMs obtained, and pending CI: Analyze (javascript-typescript), Analyze (python), Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, vale, windows-2022 / stable, and 1 discussions need to be resolved


-- commits line 2 at r1:

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: Please reference ticket in commit.

done


nativelink-util/src/health_utils.rs line 104 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: This comment doesn't have any value. There's no timeline on when/if they will ever do this, so lets just keep using it as is without a comment.

done


nativelink-util/src/store_trait.rs line 153 at r1 (raw file):

Previously, allada (Nathan (Blaise) Bruer) wrote…

ditto.

done

Copy link
Contributor

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

Reviewed 11 of 13 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: 2 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable, and 1 discussions need to be resolved

Copy link
Contributor

@adam-singer adam-singer left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 3 of 1 LGTMs obtained, and 1 discussions need to be resolved

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: 3 of 1 LGTMs obtained, and 1 discussions need to be resolved


-- commits line 2 at r2:
nit: Please use format:

Remove `#[async_trait]` where possible

closes #620

Copy link
Member

@aaronmondal aaronmondal left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 3 of 1 LGTMs obtained, and 1 discussions need to be resolved


-- commits line 2 at r2:

Previously, allada (Nathan (Blaise) Bruer) wrote…

nit: Please use format:

Remove `#[async_trait]` where possible

closes #620

nit to the nit:

Should actually have a capital C as in Closes #620 😛

Copy link
Member

@allada allada left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 1 LGTMs obtained, and 1 discussions need to be resolved

@MarcusSorealheis MarcusSorealheis enabled auto-merge (squash) June 26, 2024 19:07
Copy link
Collaborator

@MarcusSorealheis MarcusSorealheis left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 3 of 1 LGTMs obtained, and 1 discussions need to be resolved

Copy link
Contributor Author

@jhpratt jhpratt left a comment

Choose a reason for hiding this comment

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

Reviewable status: 3 of 1 LGTMs obtained, and pending CI: Analyze (javascript-typescript), Analyze (python), Bazel Dev / ubuntu-22.04, Cargo Dev / macos-13, Cargo Dev / ubuntu-22.04, Installation / macos-13, Installation / macos-14, Installation / ubuntu-22.04, Local / ubuntu-22.04, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-20.04 / stable, ubuntu-22.04, ubuntu-22.04 / stable, windows-2022 / stable


-- commits line 2 at r2:

Previously, aaronmondal (Aaron Siddhartha Mondal) wrote…

nit to the nit:

Should actually have a capital C as in Closes #620 😛

done

@MarcusSorealheis MarcusSorealheis merged commit ba168a3 into TraceMachina:main Jun 26, 2024
30 checks passed
@jhpratt jhpratt deleted the async-trait branch June 27, 2024 02:23
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.

Scale back use of async-trait where applicable
6 participants