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;
|
||||
|
||||
private readonly Lazy<IRetryPolicy?> _lazyRetryPolicy;
|
||||
|
||||
/// <summary>
|
||||
/// Controls when the client attempts to reconnect and how many times it does so.
|
||||
/// </summary>
|
||||
public IRetryPolicy? RetryPolicy => _lazyRetryPolicy.Value;
|
||||
public IRetryPolicy? RetryPolicy { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// To simplify the assignment of <seealso cref="RetryPolicy"/>
|
||||
/// </summary>
|
||||
public Func<RetryContext, TimeSpan?>? NextRetryDelay { get; set; }
|
||||
private TimeSpan? _retryDelay;
|
||||
|
||||
/// <summary>
|
||||
/// To be able to serilize the simple <seealso cref="RetryPolicy"/>
|
||||
/// </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;
|
||||
|
||||
internal void TriggerOnPublicReceivedEvent(AuthClient client, string issuer, string audience, string key, ILogger? logger = null)
|
||||
=> 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();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user