refactor(AuthClient): Ausführlichere Protokollierung hinzufügen.
This commit is contained in:
@@ -51,16 +51,23 @@ public class AuthClient : IAuthClient, IHostedService
|
||||
await GetAllPublicKeysAsync();
|
||||
}
|
||||
|
||||
private int nOfAttempts = 0;
|
||||
|
||||
private async Task<bool> TryStartConnectionAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
nOfAttempts += 1;
|
||||
await _connection.StartAsync(cancellationToken);
|
||||
_logger?.LogInformation("Auth-client connection successful. Number of connection attempts {nOfAttempts}.", nOfAttempts);
|
||||
return true;
|
||||
}
|
||||
catch(HttpRequestException ex)
|
||||
{
|
||||
_logger?.LogError(ex, "Connection is failed. {message}", ex.Message);
|
||||
if (_params.RetryDelay is null)
|
||||
_logger?.LogError(ex, "Auth-client connection failed. {message}", ex.Message);
|
||||
else
|
||||
_logger?.LogError(ex, "Auth-client connection failed and will be retried every {time} seconds. The status of being successful can be followed from the information logs.\n{message}", _params.RetryDelay.Value.TotalSeconds, ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user