refactor(ClientParams): Die Eigenschaft NextRetryDelay wurde entfernt, um die Logik zu vereinfachen.
This commit is contained in:
parent
e194cd8054
commit
d46dbbb877
@ -7,39 +7,30 @@ public class ClientParams
|
|||||||
{
|
{
|
||||||
public string Url { get; set; } = string.Empty;
|
public string Url { get; set; } = string.Empty;
|
||||||
|
|
||||||
private readonly Lazy<IRetryPolicy?> _lazyRetryPolicy;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls when the client attempts to reconnect and how many times it does so.
|
/// Controls when the client attempts to reconnect and how many times it does so.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IRetryPolicy? RetryPolicy => _lazyRetryPolicy.Value;
|
public IRetryPolicy? RetryPolicy { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
private TimeSpan? _retryDelay;
|
||||||
/// To simplify the assignment of <seealso cref="RetryPolicy"/>
|
|
||||||
/// </summary>
|
|
||||||
public Func<RetryContext, TimeSpan?>? NextRetryDelay { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// To be able to serilize the simple <seealso cref="RetryPolicy"/>
|
/// To be able to serilize the simple <seealso cref="RetryPolicy"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TimeSpan? RetryDelay { get; set; }
|
public TimeSpan? RetryDelay
|
||||||
|
{
|
||||||
|
get => _retryDelay;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
RetryPolicy = new RetryPolicy(ctx => RetryDelay);
|
||||||
|
_retryDelay = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public event ClientEvent OnPublicKeyReceived = ClientEvents.UpdatePublicKeys;
|
public event ClientEvent OnPublicKeyReceived = ClientEvents.UpdatePublicKeys;
|
||||||
|
|
||||||
internal void TriggerOnPublicReceivedEvent(AuthClient client, string issuer, string audience, string key, ILogger? logger = null)
|
internal void TriggerOnPublicReceivedEvent(AuthClient client, string issuer, string audience, string key, ILogger? logger = null)
|
||||||
=> OnPublicKeyReceived(client, issuer, audience, key, logger);
|
=> OnPublicKeyReceived(client, issuer, audience, key, logger);
|
||||||
|
|
||||||
public ClientParams()
|
|
||||||
{
|
|
||||||
_lazyRetryPolicy = new(() =>
|
|
||||||
{
|
|
||||||
if (RetryDelay is not null)
|
|
||||||
return new RetryPolicy(ctx => RetryDelay);
|
|
||||||
else if(NextRetryDelay is not null)
|
|
||||||
return new RetryPolicy(NextRetryDelay);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ClientPublicKey> PublicKeys { get; set; } = new();
|
public List<ClientPublicKey> PublicKeys { get; set; } = new();
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user