Skip to content

perf(auth): reuse a shared reqwest::Client#158

Open
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:perf/shared-reqwest-client
Open

perf(auth): reuse a shared reqwest::Client#158
SVilgelm wants to merge 1 commit into
rust-mcp-stack:mainfrom
SVilgelm:perf/shared-reqwest-client

Conversation

@SVilgelm
Copy link
Copy Markdown
Contributor

📌 Summary

OAuth discovery, metadata, and JWKS/introspection/userinfo fetches each constructed a new reqwest::Client per call, creating a fresh connection pool and TLS configuration every time. They now share one process-wide client, so requests reuse the connection pool — which matters during key-rotation events with many concurrent verifications.

🔍 Related Issues

✨ Changes Made

  • Add auth::shared_http_client() backed by a LazyLock<reqwest::Client>.
  • Use it in discovery, metadata, and the remote auth provider.
  • Use it for JWKS, introspection, and userinfo fetches in GenericOauthTokenVerifier (replacing per-call Client::new() / reqwest::get).

Touches generic_token_verifier.rs; may need a trivial rebase if #148 lands first.

OAuth discovery, metadata, and JWKS/introspection/userinfo fetches each built a fresh Client (new pool + TLS config) per call. Share one process-wide client so requests reuse the connection pool, which matters under concurrent key-rotation verifications.

Assisted-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
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.

1 participant