Skip to content

Commit

Permalink
Add overloads to DestinationState and ClusterState ctors (#2198)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonybstack authored Jul 24, 2023
1 parent a697d5b commit 208df6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ReverseProxy/Model/ClusterState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System;
using System.Collections.Concurrent;
using Microsoft.AspNetCore.Http;
using Yarp.ReverseProxy.Configuration;
using Yarp.ReverseProxy.Utilities;

namespace Yarp.ReverseProxy.Model;
Expand All @@ -24,6 +26,16 @@ public ClusterState(string clusterId)
ClusterId = clusterId ?? throw new ArgumentNullException(nameof(clusterId));
}

/// <summary>
/// Constructor overload to additionally initialize the <see cref="ClusterModel"/> for tests and infrastructure,
/// such as updating the <see cref="ReverseProxyFeature"/> via <see cref="HttpContextFeaturesExtensions"/>
/// </summary>
/// <exception cref="ArgumentNullException"><paramref name="model"/> is <see langword="null"/>.</exception>
public ClusterState(string clusterId, ClusterModel model) : this(clusterId)
{
Model = model ?? throw new ArgumentNullException(nameof(model));
}

/// <summary>
/// The cluster's unique id.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/ReverseProxy/Model/DestinationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Yarp.ReverseProxy.Utilities;

namespace Yarp.ReverseProxy.Model;
Expand All @@ -28,6 +29,16 @@ public DestinationState(string destinationId)
DestinationId = destinationId;
}

/// <summary>
/// Constructor overload to additionally initialize the <see cref="DestinationModel"/> for tests and infrastructure,
/// such as updating the <see cref="ReverseProxyFeature"/> via <see cref="HttpContextFeaturesExtensions"/>
/// </summary>
/// <exception cref="ArgumentNullException"><paramref name="model"/> is <see langword="null"/>.</exception>
public DestinationState(string destinationId, DestinationModel model) : this(destinationId)
{
Model = model ?? throw new ArgumentNullException(nameof(model));
}

/// <summary>
/// The destination's unique id.
/// </summary>
Expand Down

0 comments on commit 208df6b

Please sign in to comment.