feat(AuthClient): Konfiguration der Wiederholungsrichtlinie im Falle eines Verbindungsverlustes hinzugefügt.

This commit is contained in:
Developer 02
2025-02-11 10:33:37 +01:00
parent 484cc86a29
commit 7f39cbe24a
3 changed files with 60 additions and 10 deletions

View File

@@ -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;
});
}
}