Skip to content

Redefine sleep function into async runtime trait #2506

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

Closed
heaths opened this issue Apr 21, 2025 · 1 comment · Fixed by #2664
Closed

Redefine sleep function into async runtime trait #2506

heaths opened this issue Apr 21, 2025 · 1 comment · Fixed by #2664
Assignees
Labels
Azure.Core The azure_core crate Client This issue points to a problem in the data-plane of the library.
Milestone

Comments

@heaths
Copy link
Member

heaths commented Apr 21, 2025

We need to consolidate a lot of the async runtime behavior into a single trait that handles sleep (today, that isn't pluggable), task spawning, maybe even process spawning and file system handling. HTTP client should probably remain separate, but maybe this AsyncRuntime trait or whatever could act as a factory there.

The reason being that it's not going to be likely anyone who decides to use tokio, std-async, or other async runtime would use one for some things and another for other things. So why make callers who want to use a different, non-default async runtime (for our Azure SDK crates, which is tokio) implement (or even discover) all the traits they need to impl?

The bigger problem will be how to publish that impl. As a lib, we have to be careful with statically registering anything i.e., most likely avoid it. That has ramifications on the app that would consume us. Today, as with any other languages, we tend to pass things through IoC-style and maybe we need to keep doing that here (like we do for the HttpClient impls). Then how to "register" that impl is an app concern and they can do what is best for their app e.g., OnceLock or something.

@heaths heaths added Azure.Core The azure_core crate Client This issue points to a problem in the data-plane of the library. labels Apr 21, 2025
@heaths heaths added this to the 2025-05 milestone Apr 21, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in Azure SDK Rust Apr 21, 2025
@RickWinter RickWinter moved this from Untriaged to Not Started in Azure SDK Rust Apr 22, 2025
@LarryOsterman
Copy link
Member

One possible interesting point of reference:

https://github.com/bevyengine/bevy/tree/3d7486b01918eb84e14c3486758f9679d9711c92/crates/bevy_tasks

The bevy project has a tasks crate which implements task scheduling for the bevy runtime, including thread based tasks as well as some other implementations.

This may be interesting to leverage for Azure Core.

LarryOsterman added a commit to LarryOsterman/azure-sdk-for-rust that referenced this issue Jun 4, 2025
@github-project-automation github-project-automation bot moved this from Not Started to Done in Azure SDK Rust Jun 16, 2025
heaths added a commit to heaths/azure-sdk-for-rust that referenced this issue Jun 16, 2025
* Fixed Azure#2506, creating an AsyncRuntime trait which can be used by customers to replace the async runtime

* CI pipeline fixes

* wasm32 clippy fixes

* Fixed typo

* Minor test cleanup

* PR feedback

* PR feedback

* doctest fixes

* Added text to README.md describing how to set the async runtime used by the SDK

* Update sdk/core/azure_core/CHANGELOG.md

Co-authored-by: Heath Stewart <heaths@outlook.com>

* Policheck feedback

---------

Co-authored-by: Heath Stewart <heaths@outlook.com>
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 Client This issue points to a problem in the data-plane of the library.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants