diff --git a/TaskTackler/App.razor b/TaskTackler/App.razor index 5f4f102..59508d5 100644 --- a/TaskTackler/App.razor +++ b/TaskTackler/App.razor @@ -1,6 +1,4 @@ -@using TaskTackler.Helpers -@inject IHttpClientFactory HttpClientFactory - + @@ -14,13 +12,3 @@ - -@code { - protected override void OnInitialized() - { - var httpClient = HttpClientFactory.CreateClient("api"); - - // Start the pinging process on a background thread - _ = Task.Run(() => PingHelper.PingApiWithRetry(httpClient)); - } -} diff --git a/TaskTackler/Helpers/PingHelper.cs b/TaskTackler/Helpers/PingHelper.cs deleted file mode 100644 index 28ad310..0000000 --- a/TaskTackler/Helpers/PingHelper.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace TaskTackler.Helpers; - -public static class PingHelper -{ - public static async Task PingApi(HttpClient httpClient) - { - try - { - var response = await httpClient.GetAsync("/health"); - return response.IsSuccessStatusCode; - } - catch (Exception ex) - { - Console.WriteLine($"Error pinging API: {ex.Message}"); - return false; - } - } - - public static async Task PingApiWithRetry(HttpClient httpClient) - { - const int maxAttempts = 10; // Increase the number of attempts - const int delay = 2000; // Reduce the delay to 2 seconds between retries - - for (int attempt = 0; attempt < maxAttempts; attempt++) - { - if (await PingApi(httpClient)) - { - Console.WriteLine("API is up"); - return; - } - await Task.Delay(delay); - } - Console.WriteLine("API is down after multiple attempts"); - } -}