Repository navigation
Sync api [prototype] - #836
Open
John Batty (johnbatty) wants to merge 4 commits into
Open
John Batty (johnbatty) wants to merge 4 commits into
John Batty (johnbatty) wants to merge 4 commits into
Conversation
gen_ado.rs was an outdated copy of ado-autorust/src/main.rs, and the list_crates and owned_crates examples no longer compile. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Each module now has a generated `blocking` submodule (behind the new `blocking` feature) with a ClientBuilder that takes an HttpClient to send requests. HttpClient implementations are provided for ureq (`ureq` feature) and reqwest::blocking (`reqwest_blocking` feature). Only PAT and unauthenticated credentials are supported. Request builders are now generic over the client type (defaulting to the async client), and expose build_request() to build the HTTP request without sending it. See microsoft#835. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
azure_core's default features (async reqwest transport, tokio) are now enabled by this crate's `reqwest` feature (on by default) rather than unconditionally, so blocking-only builds using ureq don't depend on tokio, hyper or async reqwest. Default builds are unchanged. CI checks that a `--no-default-features --features git,ureq` build excludes tokio, hyper and reqwest. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Omit the `azure_` crate name prefix, as azure_core does, so blocking requests send `azsdk-rust-devops_rust_api/...` like async requests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a blocking (non-async) API alongside the existing async API, as requested in #835. It is additive and opt-in: existing async code compiles
unchanged, and default builds have the same dependencies as before.
A blocking-only build doesn't need tokio, hyper or async reqwest:
Addresses #835.
Design
RequestBuilderhas a syncbuild_request()that returns the fullazure_core::http::Request(URL, query, headers, body) without anAuthorizationheader. The asyncsend()now uses it too.RequestBuilder<C = Client>. The default keeps the async client, so code that nameslist::RequestBuilderis unaffected. Setters andbuild_request()are shared by both clients..awaitand an asyncsend().RequestBuilder<blocking::Client>has only a blockingsend(), so the compiler rejects any attempt to.awaita blocking request.blockingsubmodule (blocking::Client,blocking::ClientBuilderand a client per operation group). The HTTPclient is supplied once, when the
ClientBuilderis created, and is used for every call.blocking::HttpClienttrait (hand-written): implement it to use any HTTP client. The crate provides:UreqClient(ureqfeature)ReqwestBlockingClient(reqwest_blockingfeature), which reuses the reqwest 0.13 already in the dependency tree via azure_core.check_success.User-Agentin the same format azure_core uses.Features and dependencies
reqwest(default)blockingblockingclients and theHttpClienttraitureqblocking+UreqClientreqwest_blockingblocking+ReqwestBlockingClientreqwestfeature rather than always. Default and--all-featuresbuilds resolveexactly the same crates, versions and azure_core features as before.
default-features = false, features = ["git", "ureq"], the build doesn't depend on tokio, hyper or async reqwest (141 → 110 crates). A CI stepchecks this.
blockingfeature don't compile any blocking code.Limitations
TokenCredential(OAuth) returns an error, because getting a token is async.artifacts_downloadis async-only.reqwest_blockingstill pulls in tokio, becausereqwest::blockinguses it internally. Useureqfor a build without tokio.Breaking changes
RequestBuildertypes have a new client type parameter. It defaults to the async client, so code that names the type is unaffected.default-features = falseand use the async client no longer get azure_core's HTTP transport. They need to enable thereqwestfeature or provide their own transport; otherwise azure_core panics with a message saying the
reqwestfeature is needed.Code generator changes (
autorust)RunConfig.generate_blocking(set inado-autorust/src/main.rs) turns on blocking client generation.modules.
Cost
Measured on
cargo check/buildofazure_devops_rust_apiwith--all-features:cargo checkThe timings were measured before the blocking code was put behind the
blockingfeature, so all of it was being compiled. Builds without the featurecompile none of it.
Other changes
git_repo_list_blocking(ureq)git_repo_list_reqwest_blocking(reqwest)wit_work_item_create_blocking(a JSON Patch body)tests/blocking.rs: tests against a local mock HTTP server. The blocking tests run with both ureq and reqwest.Basicauth header,User-AgentHttpResponseerrorTokenCredentialis rejectedcargo test --all-features, so the new tests run.ureq) build and fails if tokio, hyper or reqwest are in its dependency tree.CLAUDE.mdandSKILL.mdupdates.autorust/codegen/src/bin/gen_ado.rs(an outdated copy of the generator entry point) and two codegen examples(
list_crates,owned_crates) that no longer compiled.Testing
./build.shreproduces the committed generated code.cargo fmt --check, clippy--all-features(library and examples) with--deny warnings,cargo test(default and--all-features) andcargo doc --all-featuresall pass.--no-default-featureswithgit,ureq,git,blockingandgit,reqwest_blocking.🤖 Generated with Claude Code