-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IDestinationResolver for resolving cluster destination addresses
- Loading branch information
1 parent
87511f2
commit 80648df
Showing
14 changed files
with
655 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Yarp.ReverseProxy.Configuration; | ||
|
||
/// <summary> | ||
/// Resolves destination addresses. | ||
/// </summary> | ||
public interface IDestinationResolver | ||
{ | ||
/// <summary> | ||
/// Resolves the provided destinations and returns resolved destinations. | ||
/// </summary> | ||
/// <param name="destinations">The destinations to resolve.</param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns> | ||
/// The resolved destinations and a change token used to indicate when resolution should be performed again. | ||
/// </returns> | ||
ValueTask<ResolvedDestinationCollection> ResolveDestinationsAsync( | ||
IReadOnlyDictionary<string, DestinationConfig> destinations, | ||
CancellationToken cancellationToken); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Yarp.ReverseProxy.Configuration; | ||
|
||
/// <summary> | ||
/// An <see cref="IDestinationResolver"/> which performs no action. | ||
/// </summary> | ||
internal sealed class NoOpDestinationResolver : IDestinationResolver | ||
{ | ||
public ValueTask<ResolvedDestinationCollection> ResolveDestinationsAsync(IReadOnlyDictionary<string, DestinationConfig> destinations, CancellationToken cancellationToken) | ||
=> new(new ResolvedDestinationCollection(destinations, ChangeToken: null)); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/ReverseProxy/Configuration/ResolvedDestinationCollection.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.Extensions.Primitives; | ||
|
||
namespace Yarp.ReverseProxy.Configuration; | ||
|
||
/// <summary> | ||
/// Represents a collection of resolved destinations. | ||
/// </summary> | ||
/// <param name="Destinations">The resolved destinations.</param> | ||
/// <param name="ChangeToken">An optional change token which indicates when the destination collection should be refreshed.</param> | ||
public record class ResolvedDestinationCollection(IReadOnlyDictionary<string, DestinationConfig> Destinations, IChangeToken? ChangeToken); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.