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

Add ProcessRunner trait to azure_core #2184

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

arpad-m
Copy link
Contributor

@arpad-m arpad-m commented Feb 18, 2025

Adds a ProcessRunner trait to azure_core, similar to HttpClient, and uses it in the one place in azure_identity where we used async-process before. We provide two implementations:

  • one based on tokio, behind an optional feature
  • the other (used by default) is a manual implementation with a oneshot channel and a dedicated thread

successor of #1654, #2175
fixes #1652

@github-actions github-actions bot added Azure.Core The azure_core crate Azure.Identity The azure_identity crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Feb 18, 2025
Copy link

Thank you for your contribution @arpad-m! We will review the pull request and get back to you soon.

@arpad-m arpad-m marked this pull request as draft February 18, 2025 13:20
@arpad-m arpad-m changed the title Add run_command function to azure_core Add ProcessRunner trait to azure_core Feb 18, 2025
@arpad-m arpad-m marked this pull request as ready for review February 18, 2025 16:18
Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

Thank you. This is closer, but there are still a few things we'd like to see different. I can finish this up. Just make sure that maintainers can push to your branch and I'll get to it soon. I have some other higher priority work I need to attend to first but will leave this in my queue.

@@ -0,0 +1,51 @@
use async_trait::async_trait;
Copy link
Member

Choose a reason for hiding this comment

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

Missing copyright headers found in other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Comment on lines 52 to 61
tokio_fs = ["typespec_client_core/tokio_fs"]
tokio_process = ["dep:tokio", "tokio/process"]
tokio_sleep = ["typespec_client_core/tokio_sleep"]
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: we're creating enough tokio-based features that maybe we should have a tokio feature that pulls them all in.

Comment on lines 5 to 15
#[cfg(not(feature = "tokio_process"))]
mod thread;

#[cfg(not(feature = "tokio_process"))]
pub use thread::ThreadRunner;

#[cfg(feature = "tokio_process")]
pub use tokio::TokioRunner;

#[cfg(feature = "tokio_process")]
mod tokio {
Copy link
Member

Choose a reason for hiding this comment

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

It'd be better to just isolate these into separate modules and conditionally pull them in if enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +5 to +9
#[cfg(not(feature = "tokio_process"))]
mod thread;
Copy link
Member

Choose a reason for hiding this comment

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

You should never use mutually-exclusive features as called out in rust docs. The resolver does a union.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no feature that's mutually exclusive with tokio_process: either it's present, or it's not. If there would be multiple features, from multiple backends, then there would be a problem indeed. But this isn't the case here.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with there being no default implementation if you disable our default. In that case, it's up to the callers to provide one and is the current plan with an internal team focused on Azure services.

Comment on lines -29 to -31
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
async-process.workspace = true

Copy link
Member

Choose a reason for hiding this comment

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

This should be removed from the workspace if it's the only one referencing it left.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@arpad-m
Copy link
Contributor Author

arpad-m commented Feb 21, 2025

I can finish this up. Just make sure that maintainers can push to your branch and I'll get to it soon.

I made this PR from a company owned fork of the repository which is a bit locked down. The "allow maintainers to do changes" checkbox doesn't even appear when making new pull requests from it. But feel free to cherry-pick changes from my branch to a new PR that you file.

@arpad-m arpad-m force-pushed the arpad/async-abstraction-2 branch from a47a129 to dbc1036 Compare March 5, 2025 12:38
@arpad-m arpad-m requested a review from heaths March 5, 2025 12:38
@heaths
Copy link
Member

heaths commented Mar 11, 2025

To note: I haven't forgotten about this and will be working on it soon. I have a couple more things I want to get done first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core The azure_core crate Azure.Identity The azure_identity crate Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Async process abstractions
2 participants