Skip to content
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

Service Discovery: make scheme selection more intuitive in un-specified case, add more tests #3837

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Apr 19, 2024

Make scheme selection more intuitive

  • If ServiceDiscoveryOptions.AllowAllSchemes is TRUE and the service name INCLUDES schemes (eg https://basket), we filter out results which do not have a matching scheme, applying the preference. i.e, https+http means pick only https endpoints if any https endpoints are present, http only if no https endpoints are present.
  • If ServiceDiscoveryOptions.AllowAllSchemes is TRUE and the service name DOES NOT INCLUDE schemes (eg, basket), then we should allow all endpoints.
  • If ServiceDiscoveryOptions.AllowAllSchemes is FALSE, the service name DOES NOT INCLUDE schemes, and ServiceDiscoveryOptions.AllowedSchemes contains some value (eg, ["https"]), then we should filter to include only endpoints matching those AllowedSchemes values.

In pseudo code, the logic is:

IncludeAll = AllowAllSchemes && ServiceName.Schemes.Count == 0
IncludedSchemes = ServiceName.Schemes.Count > 0 ? ServiceName.Schemes.Intersect(AllowedSchemes) : AllowedSchemes

Always check "default" config section first when no endpoint name is specified

  • When searching for a configuration section for a service and no endpoint name has been specified (i.e, the common case), we should first check the "default" section, then the sections corresponding to schemes. The current behavior is:
    • If the query specified any schemes, check those sections in order (https+http -> check "https" then "http" cfg sections)
    • If the query does not specify any schemes, check the "default" section.

The change is to always check the default section first if no endpoint name is specified.

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond merged commit cea412a into main Apr 19, 2024
8 checks passed
@ReubenBond ReubenBond deleted the rebond/fix/sd-cfg-scheme-selection-defaults branch April 19, 2024 20:54
@ReubenBond
Copy link
Member Author

/backport to release/8.0

Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8759708724

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants