From ccb265d61e9da89d7460a5c5ee3c8aea9c1e3c14 Mon Sep 17 00:00:00 2001 From: KirillKurdyukov Date: Tue, 5 Mar 2024 19:22:55 +0300 Subject: [PATCH] refactoring --- src/Ydb.Sdk/src/Driver.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Ydb.Sdk/src/Driver.cs b/src/Ydb.Sdk/src/Driver.cs index 33c8178d..357cb323 100644 --- a/src/Ydb.Sdk/src/Driver.cs +++ b/src/Ydb.Sdk/src/Driver.cs @@ -82,9 +82,7 @@ public async Task Initialize() } _logger.LogInformation("Started initial endpoint discovery"); - - var successDiscover = false; - + for (var i = 0; i < _config.AttemptDiscovery; i++) { try @@ -92,8 +90,9 @@ public async Task Initialize() var status = await DiscoverEndpoints(); if (status.IsSuccess) { - successDiscover = true; - break; + _ = Task.Run(PeriodicDiscovery); + + return; } _logger.LogCritical($"Error during initial endpoint discovery: {status}"); @@ -103,13 +102,8 @@ public async Task Initialize() _logger.LogCritical($"RPC error during initial endpoint discovery: {e.Status}"); } } - - if (!successDiscover) - { - throw new InitializationFailureException("Error during initial endpoint discovery"); - } - - _ = Task.Run(PeriodicDiscovery); + + throw new InitializationFailureException("Error during initial endpoint discovery"); } internal async Task> UnaryCall(