Skip to content

Auto-enable thin client under gateway mode#48096

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/auto-enable-thin-client
Draft

Auto-enable thin client under gateway mode#48096
Copilot wants to merge 2 commits intomainfrom
copilot/auto-enable-thin-client

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

When using gatewayMode(), the SDK should transparently route data-plane requests through the thin client proxy (port 10250) when the account's gateway metadata indicates thin client endpoints are available — with no new public API required.

Changes

  • Configs.java: Flipped DEFAULT_THINCLIENT_ENABLED from falsetrue. Thin client is now opt-out via COSMOS.THINCLIENT_ENABLED=false (system property) or COSMOS_THINCLIENT_ENABLED=false (env var).

  • RxDocumentClientImpl.java:

    • Removed the HTTP/2 configuration pre-check from useThinClient. The condition is now simply isThinClientEnabled() && GATEWAY mode. Runtime availability is already gated by useThinClientStoreModel()hasThinClientReadLocations().
    • Added a dedicated thinClientReactorHttpClient (HTTP/2 force-enabled) created in init() only when useThinClient=true. The existing reactorHttpClient used by the gateway proxy retains HTTP/1.1 — the two are fully separate.
    • thinClientHttpClient() preserves any user-supplied Http2ConnectionConfig pool/stream settings while forcing enabled=true.
    • close() shuts down thinClientReactorHttpClient when it was created.
    • addUserAgentSuffix() now uses the useThinClient instance flag (more accurate than re-reading Configs.isThinClientEnabled()).
  • ConfigsTests.java: Updated thinClientEnabledTest — default is now true; test verifies opt-out with false.

Routing behavior

Request type Connection
Metadata / control plane Gateway proxy → port 443 (HTTP/1.1)
Data plane (when thin client locations present) Thin proxy → port 10250 (HTTP/2)
Data plane (no thin client locations in account) Gateway proxy → port 443 (falls back transparently)

The THINCLIENT_OPT_IN header is sent on the database account metadata request so the gateway returns thin client endpoint locations, which GlobalEndpointManager then uses to set hasThinClientReadLocations.

Original prompt

This section details on the original issue you should resolve

<issue_title>[FEATURE REQ] [Thin client]: Auto-enable thin client under gateway mode</issue_title>
<issue_description>## Summary

When a user calls CosmosClientBuilder.gatewayMode(), the SDK should automatically route through the thin client proxy (port 10250) if the account's gateway metadata response indicates a thin client endpoint is available. No new ConnectionMode enum value is needed — thin client IS gateway mode, just over HTTP/2 to a co-located proxy instead of HTTPS to the gateway frontend.

Expected Behavior

  • gateway() mode auto-detects thin client endpoint from gateway metadata response
  • If available, routes data plane requests through thin client proxy (port 10250)
  • Metadata/control plane requests continue to use port 443
  • System property COSMOS.THINCLIENT_ENABLED=false available as opt-out escape hatch
  • No new public API surface — transparent to users</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: jeet1995 <16476407+jeet1995@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable automatic use of thin client in gateway mode Auto-enable thin client under gateway mode Feb 24, 2026
Copilot AI requested a review from jeet1995 February 24, 2026 20:19
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.

[FEATURE REQ] [Thin client]: Auto-enable thin client under gateway mode

2 participants