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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8e9ac85
API review feedback & general cleanup including removal of currently …
ReubenBond Mar 11, 2024
8675c4a
Align namespaces
ReubenBond Mar 11, 2024
0ca05ec
Hide more of the API, rename for consistency
ReubenBond Mar 11, 2024
569e333
Hide more, rename more
ReubenBond Mar 11, 2024
fb5eb6c
ResolutionStatus does not need to be equatable
ReubenBond Mar 11, 2024
3a1edb5
Make ServiceEndPointQuery public to break InternalsVisibleTo with Dns…
ReubenBond Mar 22, 2024
6ce4d7c
Break InternalsVisibleTo from ServiceDiscovery package to YARP by add…
ReubenBond Mar 22, 2024
fa340b3
Remove ResolutionStatus, simplifying Service Discovery interfaces
ReubenBond Mar 22, 2024
5311e2b
Clean up ServiceEndPointImpl
ReubenBond Mar 22, 2024
8abd0c1
Mark ServiceEndPointResolverResult as internal
ReubenBond Mar 22, 2024
30ae362
Remove unnecessary members from ServiceEndPointCollection/Source
ReubenBond Mar 22, 2024
557f1a9
Seal service discovery types
ReubenBond Mar 22, 2024
b7d4a94
Remove IServiceEndPointSelectorFactory and use DI instead
ReubenBond Mar 22, 2024
eca13a5
Remove unused endpoint selectors
ReubenBond Mar 22, 2024
549a378
Remove unused PendingStatusRefreshPeriod option
ReubenBond Mar 22, 2024
8dad949
Rename UseServiceDiscovery to AddServiceDiscovery
ReubenBond Mar 22, 2024
a277bea
Remove possible ambiguity in AddConfigurationServiceEndPointResolver …
ReubenBond Mar 22, 2024
d66b007
Add configuration delegate overloads to AddServiceDiscovery methods
ReubenBond Mar 22, 2024
356ce50
Clean up logging in configuration-based service endpoint provider
ReubenBond Mar 22, 2024
3487ff9
API review: rename ServiceEndPointCollectionSource to IServiceEndPoin…
ReubenBond Mar 25, 2024
2e57031
Rename IServiceDiscoveryDelegatingHttpMessageHandlerFactory
ReubenBond Mar 25, 2024
b67df01
Rename IServiceEndPointProvider.ResolveAsync to PopulateAsync
ReubenBond Mar 25, 2024
0cb8f8c
Hide IServiceEndPointSelector
ReubenBond Mar 25, 2024
775a976
Remove allowedSchemes from ServiceEndPointQuery.TryParse
ReubenBond Mar 25, 2024
95e314d
Rename ServiceEndPointQuery.Host to .ServiceName
ReubenBond Mar 25, 2024
10c4ecc
Fix build
ReubenBond Mar 25, 2024
7032dcd
Review feedback
ReubenBond Mar 25, 2024
af38760
nit param rename
ReubenBond Mar 25, 2024
aa34b62
Improve ServiceEndPointQuery.ToString output
ReubenBond Mar 25, 2024
7814449
fixup
ReubenBond Mar 26, 2024
4955f3b
Add blame to tests in CI
ReubenBond Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion playground/AWS/AWS.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
Expand Down
2 changes: 1 addition & 1 deletion playground/Playground.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
Expand Down
2 changes: 1 addition & 1 deletion playground/TestShop/ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
Expand Down
2 changes: 1 addition & 1 deletion playground/orleans/OrleansServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
Expand Down
2 changes: 1 addition & 1 deletion playground/seq/Seq.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.UseServiceDiscovery();
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Extensions.ServiceDiscovery.Abstractions;
namespace Microsoft.Extensions.ServiceDiscovery;

/// <summary>
/// Exposes the host name of the end point.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;

namespace Microsoft.Extensions.ServiceDiscovery;

/// <summary>
/// Builder to create a <see cref="ServiceEndPointSource"/> instances.
/// </summary>
public interface IServiceEndPointBuilder
{
/// <summary>
/// Gets the endpoints.
/// </summary>
IList<ServiceEndPoint> EndPoints { get; }

/// <summary>
/// Gets the feature collection.
/// </summary>
IFeatureCollection Features { get; }

/// <summary>
/// Adds a change token to the resulting <see cref="ServiceEndPointSource"/>.
/// </summary>
/// <param name="changeToken">The change token.</param>
void AddChangeToken(IChangeToken changeToken);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Extensions.ServiceDiscovery.Abstractions;
namespace Microsoft.Extensions.ServiceDiscovery;

/// <summary>
/// Provides details about a service's endpoints.
Expand All @@ -14,5 +14,5 @@ public interface IServiceEndPointProvider : IAsyncDisposable
/// <param name="endPoints">The endpoint collection, which resolved endpoints will be added to.</param>
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
/// <returns>The resolution status.</returns>
ValueTask<ResolutionStatus> ResolveAsync(ServiceEndPointCollectionSource endPoints, CancellationToken cancellationToken);
ValueTask PopulateAsync(IServiceEndPointBuilder endPoints, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Extensions.ServiceDiscovery.Abstractions;
namespace Microsoft.Extensions.ServiceDiscovery;

/// <summary>
/// Creates <see cref="IServiceEndPointProvider"/> instances.
/// </summary>
public interface IServiceEndPointResolverProvider
public interface IServiceEndPointProviderFactory
{
/// <summary>
/// Tries to create an <see cref="IServiceEndPointProvider"/> instance for the specified <paramref name="serviceName"/>.
/// Tries to create an <see cref="IServiceEndPointProvider"/> instance for the specified <paramref name="query"/>.
/// </summary>
/// <param name="serviceName">The service to create the resolver for.</param>
/// <param name="query">The service to create the resolver for.</param>
/// <param name="resolver">The resolver.</param>
/// <returns><see langword="true"/> if the resolver was created, <see langword="false"/> otherwise.</returns>
bool TryCreateResolver(string serviceName, [NotNullWhen(true)] out IServiceEndPointProvider? resolver);
bool TryCreateProvider(ServiceEndPointQuery query, [NotNullWhen(true)] out IServiceEndPointProvider? resolver);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
using System.Net;
using Microsoft.AspNetCore.Http.Features;

namespace Microsoft.Extensions.ServiceDiscovery.Abstractions;
namespace Microsoft.Extensions.ServiceDiscovery.Internal;

internal sealed class ServiceEndPointImpl : ServiceEndPoint
internal sealed class ServiceEndPointImpl(EndPoint endPoint, IFeatureCollection? features = null) : ServiceEndPoint
{
private readonly IFeatureCollection _features;
private readonly EndPoint _endPoint;

public ServiceEndPointImpl(EndPoint endPoint, IFeatureCollection? features = null)
{
_endPoint = endPoint;
_features = features ?? new FeatureCollection();
}

public override EndPoint EndPoint => _endPoint;
public override IFeatureCollection Features => _features;

public override EndPoint EndPoint { get; } = endPoint;
public override IFeatureCollection Features { get; } = features ?? new FeatureCollection();
public override string? ToString() => GetEndPointString();
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using System.Diagnostics;
using System.Net;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.ServiceDiscovery.Internal;

namespace Microsoft.Extensions.ServiceDiscovery.Abstractions;
namespace Microsoft.Extensions.ServiceDiscovery;

/// <summary>
/// Represents an endpoint for a service.
Expand Down
Loading