-
Notifications
You must be signed in to change notification settings - Fork 689
Add method to create YarpCluster with a list of string as addresses #11368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method to create YarpCluster with a list of string as addresses #11368
Conversation
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11368 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11368" |
There was a problem hiding this comment.
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 adds a new constructor to the YarpCluster
class that accepts a list of string addresses, enabling load balancing across multiple endpoints. This change resolves issue #10751 by allowing YARP clusters to target multiple destinations directly from string addresses.
- Adds a new
YarpCluster
constructor that accepts aparams string[] addresses
parameter - Updates the internal data structure from a single
Target
to an array ofTargets
- Modifies the environment variable generation to support multiple destinations
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs | Adds new constructor for string addresses and changes internal structure to support multiple targets |
src/Aspire.Hosting.Yarp/YarpEnvConfigGenerator.cs | Updates environment variable generation to iterate through multiple targets |
tests/Aspire.Hosting.Yarp.Tests/YarpClusterTests.cs | Adds test for new constructor and updates existing tests to use new Targets array |
/// </summary> | ||
/// <param name="clusterName">The name of the cluster.</param> | ||
/// <param name="addresses">The external addresses.</param> | ||
internal YarpCluster(string clusterName, params string[] addresses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan to have a string and then an optional addrya for the list of addresses. We could use Uri
instead?
This allows for creating a cluster without any destinations, I think we need to support passing an array not params |
Description
Add a method to build a
YarpCluster
with a collection of string to use as addresses.Fixes #10751
Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template