Skip to content

[config]: Support multiple named upstreams#54

Open
pseudomuto wants to merge 1 commit into
mainfrom
pluralize_upstream
Open

[config]: Support multiple named upstreams#54
pseudomuto wants to merge 1 commit into
mainfrom
pluralize_upstream

Conversation

@pseudomuto

Copy link
Copy Markdown
Collaborator

The proxy held a single Config.Upstream, which blocks the dynamic routing work (RFC #32): routing rules need to refer to upstreams by name, and a deployment serves more than one. This replaces it with Config.Upstreams, a named list, as the foundation for the routing block, engine, and connection registry that will follow.

Upstream targets may be templated (e.g. "{{ .RemoteNamespace }}.acme:7233") once rendering lands, so Upstream.Validate skips the literal IsHostPort check when the value contains a template action; a static hostPort is still validated. The inbound ListenConfig.Validate stays strict, since a listener address is never templated.

Config.PrimaryUpstream returns the first entry as an explicit, documented bridge rather than scatter an Upstreams[0] assumption across the fx modules; it will be removed when routing selects the upstream per request.

@pseudomuto pseudomuto requested a review from Copilot June 30, 2026 19:21
@pseudomuto pseudomuto requested a review from a team as a code owner June 30, 2026 19:21
@codecov-commenter

codecov-commenter commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.97%. Comparing base (ad23f91) to head (2d64a9e).

Files with missing lines Patch % Lines
internal/proxy/fx.go 75.00% 1 Missing and 1 partial ⚠️
internal/router/fx.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #54      +/-   ##
==========================================
- Coverage   85.12%   84.97%   -0.16%     
==========================================
  Files          33       33              
  Lines        1042     1058      +16     
==========================================
+ Hits          887      899      +12     
- Misses        131      133       +2     
- Partials       24       26       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR evolves the proxy configuration from a single upstream to a list of named upstreams, enabling upcoming dynamic routing work (RFC #32) while providing a temporary “primary upstream” bridge for existing wiring.

Changes:

  • Replace Config.Upstream with Config.Upstreams []Upstream and add Config.PrimaryUpstream() for transitional single-upstream consumers.
  • Add Upstream.Name plus validation for required/unique names, and relax upstream hostPort validation when a value appears templated.
  • Update fx modules/tests and dev config YAML to use the new upstreams schema.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/server/fx_test.go Update server module tests to supply Upstreams instead of Upstream.
internal/router/fx.go Switch router wiring to derive socket path from PrimaryUpstream().
internal/router/fx_test.go Update router module tests to use Upstreams.
internal/proxy/fx.go Resolve and validate the primary upstream before constructing the proxy; derive creds from selected upstream.
internal/proxy/fx_test.go Update proxy module tests to use Upstreams.
internal/config/upstream.go Add upstream Name and update validation (including templated hostPort handling).
internal/config/upstream_test.go Adjust YAML fixtures and validation tests to the new upstreams schema.
internal/config/config.go Introduce Upstreams, per-upstream validation, unique-name validation, and PrimaryUpstream().
internal/config/config_test.go Extend validation coverage for missing/duplicate names and PrimaryUpstream().
dev/config.yaml Update example dev configuration to use upstreams: list with named entry.

Comment thread internal/config/config.go
Comment thread internal/config/upstream.go
The proxy held a single Config.Upstream, which blocks the dynamic routing
work (RFC #32): routing rules need to refer to upstreams by name, and a
deployment serves more than one. This replaces it with Config.Upstreams, a
named list, as the foundation for the routing block, engine, and connection
registry that will follow.

Upstream targets may be templated (e.g. "{{ .RemoteNamespace }}.acme:7233")
once rendering lands, so Upstream.Validate skips the literal IsHostPort check
when the value contains a template action; a static hostPort is still
validated. The inbound ListenConfig.Validate stays strict, since a listener
address is never templated.

Config.PrimaryUpstream returns the first entry as an explicit,
documented bridge rather than scatter an Upstreams[0] assumption across
the fx modules; it will be removed when routing selects the upstream per
request.
@pseudomuto pseudomuto force-pushed the pluralize_upstream branch from f1e9072 to 2d64a9e Compare June 30, 2026 19:33
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