Skip to content

Add cluster recommendations API support to SDKs#653

Merged
ArunGopinathan merged 1 commit into
mainfrom
dev/agopinathan/cluster-recommendations-api
Jun 19, 2026
Merged

Add cluster recommendations API support to SDKs#653
ArunGopinathan merged 1 commit into
mainfrom
dev/agopinathan/cluster-recommendations-api

Conversation

@ArunGopinathan

Copy link
Copy Markdown
Contributor

Adds support for the new tunnels Cluster Recommendations API across the C#, TypeScript, and Go SDKs (with generated contracts for Java and Rust). The SDK can now automatically select the best cluster for a new tunnel, optionally constrained by a required geography, while remaining fully backward compatible.

Contracts (C# source-of-truth, auto-generated to TS/Go/Java/Rust):

  • ClusterAvailability, ClusterRecommendation, ClusterRecommendationResponse
  • Generator: add float/double type mappings (TS/Go/Java/Rust writers)

What changed

  • New management methodGetClusterRecommendations(preferredClusterId, requiredGeo) (C#/TS/Go, plus interface + mocks) returns ranked cluster recommendations.
  • Auto-recommend on createCreateTunnel now, when no cluster is specified, calls the recommendations API and creates the tunnel in the recommended cluster. Any failure is swallowed and the call falls back to normal global (Traffic Manager) routing. If a cluster is already set, the recommendations call is skipped.
  • RequiredGeo request option — added to TunnelRequestOptions in all three SDKs. It is forwarded only on the recommendations request and is intentionally excluded from the create-tunnel query string.
  • New contractsClusterAvailability, ClusterRecommendation, ClusterRecommendationResponse (generated for all languages from the C# source).

Notable fix

  • Go buildUri aliasing bugbuildUri mutated the shared m.uri (*url.URL) in place. Latent before, but auto-recommend now sets ClusterID, which made the base URI get permanently pinned to the recommended cluster's host for all subsequent requests. Fixed by copying the URL by value; added a dedicated regression test.

Testing

  • Unit tests: C# 136 passing · TS 81 passing · Go CreateTunnel suite passing (incl. new parity + regression tests covering: recommend-when-unset, skip-when-set, RequiredGeo forwarding, RequiredGeo excluded from create, and no base-URI mutation).
  • Packaged E2E: Built the SDK to a local NuGet feed and ran a console consumer (referencing the package, not source) against a mock service — verified at runtime that auto-recommend issues the /clusters/recommendations GET first, creates the tunnel in the returned cluster, and deletes it; RequiredGeo rides the recommendations request and is absent from the create request.

Pre-PR checklist

  • Go PackageVersion bumped 0.1.260.1.27 in go/tunnels/tunnels.go (per the patch-per-PR convention).
  • TS package.json floorsconnections and management already require @microsoft/dev-tunnels-contracts / -management at >1.3.50, which is greater than the current published 1.3.48. (CI rewrites these to concrete versions at publish time.) No change needed.

Compatibility

Fully backward compatible. Existing callers that set a cluster, or that don't, behave exactly as before — the only new behavior is automatic cluster selection when none is provided, with graceful fallback on any error.

Add the cluster recommendations API across the C#, TypeScript, and Go SDKs
so tunnel creation can auto-select an optimal cluster when none is specified.

Contracts (C# source-of-truth, auto-generated to TS/Go/Java/Rust):
- ClusterAvailability, ClusterRecommendation, ClusterRecommendationResponse
- Generator: add float/double type mappings (TS/Go/Java/Rust writers)

Management clients:
- GetClusterRecommendations(Async) in C#, TS, Go (preferredClusterId, requiredGeo)
- Auto-recommend in CreateTunnel (C#, TS, Go) when ClusterId is unset; errors
  fall back to global routing
- RequiredGeo on TunnelRequestOptions (C#, TS, Go) forwarded to the auto-recommend
  call only (excluded from the create request query string)

Tests: unit coverage for recommendations, auto-recommend, geo forwarding, and
skip-when-cluster-set across C#, TS, and Go.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ArunGopinathan ArunGopinathan merged commit a18b41f into main Jun 19, 2026
9 checks passed
@ArunGopinathan ArunGopinathan deleted the dev/agopinathan/cluster-recommendations-api branch June 19, 2026 20:25
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.

3 participants