feat(rust): Add RequestExecutor trait for CLI execution-sharing#16282
Conversation
Add RequestExecutor trait and HttpClient::with_executor() constructor to enable CLI execution-sharing. When an external executor is injected, the SDK delegates HTTP execution entirely — auth, headers, and retries are handled by the caller's transport stack. Also adds cliEmbedded config flag that skips model generation when the SDK is embedded in a CLI binary.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Security Finding:
|
|
The new commit (
// Build the request
let mut req = request.build().map_err(|e| ApiError::Network(e))?;
// Apply authentication and headers
self.apply_auth_headers(&mut req, &options).await?;
self.apply_custom_headers(&mut req, &options)?;
// Execute with retries
let response = self.execute_with_retries(req, &options).await?;The injected |
SDK Generation Benchmark ResultsComparing PR branch against median of 5 nightly run(s) on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
…or, fix cliEmbedded types - Restore #[derive(Clone)] on HttpClient (needed for pagination code gen) - Update BASE64_METHOD template to use send_request() instead of direct apply_auth_headers/execute_with_retries (bypassed injected executor) - Check cliEmbedded flag in generateApiModFile and generateLibFile to avoid declaring mod types when type generation is skipped
Move SSE-specific headers (Accept: text/event-stream, Cache-Control: no-store) after apply_custom_headers in the default path so they always take precedence, matching the original ordering. In the executor path, SSE headers are applied before delegation.
…-sdk-transport-seam
Description
Linear ticket: Refs FER-11025
Adds a transport seam to the Rust SDK generator: a
RequestExecutortrait andHttpClient::with_executor()constructor that lets a CLI binary inject its own HTTP execution stack into the generated SDK. This is the foundational change for co-generating the Rust SDK into a CLI and exposing an execution-sharing boundary.Changes Made
generators/rust/base/src/asIs/http_client.rs(template):RequestExecutortrait (Send + Sync, returnsBoxFuture<Result<Response, reqwest::Error>>)ReqwestExecutordefault impl wrappingreqwest::Client— preserves standalone SDK behavior unchangedHttpClient::with_executor(Arc<dyn RequestExecutor>, ClientConfig)constructor — when used, the SDK delegates HTTP execution entirely (no SDK-level auth/headers/retries, preventing double-retry)send_request()which branches between executor path and default pathHttpClientretains#[derive(Clone)](all fields includingOption<Arc<dyn RequestExecutor>>are Clone-compatible)generators/rust/base/src/project/RustProject.ts(template expansion):send_request()dispatchergenerators/rust/sdk/src/SdkGeneratorCli.ts:RequestExecutorfromcore/mod.rscliEmbedded: truegenerateApiModFileandgenerateLibFilerespectcliEmbeddedflag (nomod types;when types are skipped)generators/rust/sdk/src/SdkCustomConfig.ts:cliEmbedded: booleanconfig flag (defaults tofalse)Seed snapshots: All 135 rust-sdk fixtures regenerated with updated
http_client.rsandcore/mod.rsTesting
pnpm check(biome lint) passes — 4821 files checked, no issuesdist:clibuild succeeds — as-is template files correctly bundledLink to Devin session: https://app.devin.ai/sessions/2af7dccaec8640ff8d8e7673c0170a2b
Requested by: @jsklan