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 API refactoring #3114

Merged
merged 31 commits into from
Mar 26, 2024
Merged

Service Discovery API refactoring #3114

merged 31 commits into from
Mar 26, 2024

Conversation

ReubenBond
Copy link
Member

@ReubenBond ReubenBond commented Mar 22, 2024

Our requirements on Service Discovery have evolved since we first created it, eg we added more semantics to the input string. There were also some vestigial types, members, and patterns to clean up. API review also revealed some things which could be simplified or changed to align with prevailing patterns.

This PR addresses these points by refactoring the API:

  • Move types in the *.Abstractions assembly out of the .Abstractions namespace, and clean up namespaces in general
  • Hide types & members which do not need to be exposed. Delete unused types (eg, unused IServiceEndPointSelector impls).
  • Seal most types
  • Simplify the resolver API by removing the ResolutionStatus type
  • Rename IHttpClientBuilder extension from UseServiceDiscovery to AddServiceDiscovery to align with existing patterns. The existing method is kept and marked as [Obsolete] for now.
  • Add a ServiceEndPointQuery type to communicate the parsed input from the core resolver to the providers
  • Resolve IServiceEndPointSelector from DI instead of using a factory (and register it as transient).
  • Add missing overloads to hosting methods. Specifically, overloads which accept configuration delegates.
  • General code style cleanup (primary constructors, etc)
  • Rename ServiceEndPointCollectionSource to ServiceEndPointBuilder, make internal, and extract public interface: IServiceEndPointBuilder
  • Rename ServiceEndPointCollection to ServiceEndPointSource to match existing ASP.NET pattern
Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond marked this pull request as draft March 22, 2024 21:20
@ReubenBond ReubenBond marked this pull request as ready for review March 22, 2024 21:32
@ReubenBond ReubenBond force-pushed the rebond/sd-api-review branch from a75d7c9 to 032d309 Compare March 25, 2024 16:27
@ReubenBond ReubenBond force-pushed the rebond/sd-api-review branch 3 times, most recently from 2224161 to 619ec31 Compare March 25, 2024 22:59
@ReubenBond
Copy link
Member Author

image
We should merge this for this fact alone

@ReubenBond ReubenBond enabled auto-merge (squash) March 26, 2024 00:48
@ReubenBond ReubenBond force-pushed the rebond/sd-api-review branch from 8ce0fe6 to 5b1d46a Compare March 26, 2024 16:16
@ReubenBond ReubenBond force-pushed the rebond/sd-api-review branch 3 times, most recently from ee12f51 to ca68d2d Compare March 26, 2024 20:29
@ReubenBond ReubenBond force-pushed the rebond/sd-api-review branch from ca68d2d to 4955f3b Compare March 26, 2024 21:01
@ReubenBond ReubenBond merged commit 23104ee into main Mar 26, 2024
8 checks passed
@ReubenBond ReubenBond deleted the rebond/sd-api-review branch March 26, 2024 21:51
ReubenBond added a commit that referenced this pull request Mar 26, 2024
* API review feedback & general cleanup including removal of currently unused features

* Align namespaces

* Hide more of the API, rename for consistency

* Hide more, rename more

* ResolutionStatus does not need to be equatable

* Make ServiceEndPointQuery public to break InternalsVisibleTo with Dns provider

* Break InternalsVisibleTo from ServiceDiscovery package to YARP by adding a middleware factory

* Remove ResolutionStatus, simplifying Service Discovery interfaces

* Clean up ServiceEndPointImpl

* Mark ServiceEndPointResolverResult as internal

* Remove unnecessary members from ServiceEndPointCollection/Source

* Seal service discovery types

* Remove IServiceEndPointSelectorFactory and use DI instead

* Remove unused endpoint selectors

* Remove unused PendingStatusRefreshPeriod option

* Rename UseServiceDiscovery to AddServiceDiscovery

* Remove possible ambiguity in AddConfigurationServiceEndPointResolver signature

* Add configuration delegate overloads to AddServiceDiscovery methods

* Clean up logging in configuration-based service endpoint provider

* API review: rename ServiceEndPointCollectionSource to IServiceEndPointBuilder

* Rename IServiceDiscoveryDelegatingHttpMessageHandlerFactory

* Rename IServiceEndPointProvider.ResolveAsync to PopulateAsync

* Hide IServiceEndPointSelector

* Remove allowedSchemes from ServiceEndPointQuery.TryParse

* Rename ServiceEndPointQuery.Host to .ServiceName

* Fix build

* Review feedback

* nit param rename

* Improve ServiceEndPointQuery.ToString output

* fixup

(cherry picked from commit 23104ee)
davidfowl pushed a commit that referenced this pull request Mar 27, 2024
* API review feedback & general cleanup including removal of currently unused features

* Align namespaces

* Hide more of the API, rename for consistency

* Hide more, rename more

* ResolutionStatus does not need to be equatable

* Make ServiceEndPointQuery public to break InternalsVisibleTo with Dns provider

* Break InternalsVisibleTo from ServiceDiscovery package to YARP by adding a middleware factory

* Remove ResolutionStatus, simplifying Service Discovery interfaces

* Clean up ServiceEndPointImpl

* Mark ServiceEndPointResolverResult as internal

* Remove unnecessary members from ServiceEndPointCollection/Source

* Seal service discovery types

* Remove IServiceEndPointSelectorFactory and use DI instead

* Remove unused endpoint selectors

* Remove unused PendingStatusRefreshPeriod option

* Rename UseServiceDiscovery to AddServiceDiscovery

* Remove possible ambiguity in AddConfigurationServiceEndPointResolver signature

* Add configuration delegate overloads to AddServiceDiscovery methods

* Clean up logging in configuration-based service endpoint provider

* API review: rename ServiceEndPointCollectionSource to IServiceEndPointBuilder

* Rename IServiceDiscoveryDelegatingHttpMessageHandlerFactory

* Rename IServiceEndPointProvider.ResolveAsync to PopulateAsync

* Hide IServiceEndPointSelector

* Remove allowedSchemes from ServiceEndPointQuery.TryParse

* Rename ServiceEndPointQuery.Host to .ServiceName

* Fix build

* Review feedback

* nit param rename

* Improve ServiceEndPointQuery.ToString output

* fixup

(cherry picked from commit 23104ee)
@danmoseley danmoseley mentioned this pull request Apr 12, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 2024
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.

3 participants