[config]: Support multiple named upstreams#54
Open
pseudomuto wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.UpstreamwithConfig.Upstreams []Upstreamand addConfig.PrimaryUpstream()for transitional single-upstream consumers. - Add
Upstream.Nameplus validation for required/unique names, and relax upstreamhostPortvalidation 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. |
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.
f1e9072 to
2d64a9e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.