feat(AuthClient): Konfiguration der Wiederholungsrichtlinie im Falle eines Verbindungsverlustes hinzugefügt.
This commit is contained in:
@@ -1,10 +1,39 @@
|
||||
namespace DigitalData.Auth.Client;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
|
||||
namespace DigitalData.Auth.Client;
|
||||
|
||||
public class ClientParams
|
||||
{
|
||||
#pragma warning disable CS8618 // throw exception in DI extension if it not set
|
||||
public string Url { get; set; }
|
||||
#pragma warning restore CS8618
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// To simplify the assignment of <seealso cref="RetryPolicy"/>
|
||||
/// </summary>
|
||||
public Func<RetryContext, TimeSpan?>? NextRetryDelay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// To be able to serilize the simple <seealso cref="RetryPolicy"/>
|
||||
/// </summary>
|
||||
public TimeSpan? RetryDelay { get; set; }
|
||||
|
||||
public readonly ClientEvents Events = new();
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user