Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move the BackoffWrapper into api #249

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) Red Hat 2023 */
package com.redhat.insights.core.httpclient;
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.http;

import static com.redhat.insights.InsightsErrorCode.ERROR_CLIENT_BACKOFF_RETRIES_FAILED;
import static com.redhat.insights.InsightsErrorCode.ERROR_INTERRUPTED_THREAD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) Red Hat 2023 */
package com.redhat.insights.core.httpclient;
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.http;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -13,16 +13,16 @@ class BackoffWrapperTest {

@Test
void notFailingAction() {
var logger = PrintLogger.STDOUT_LOGGER;
var backoff = new BackoffWrapper(logger, 100L, 2L, 3, () -> {});
PrintLogger logger = PrintLogger.STDOUT_LOGGER;
BackoffWrapper backoff = new BackoffWrapper(logger, 100L, 2L, 3, () -> {});
assertEquals(0, backoff.run());
}

@Test
void alwaysFailingAction() {
var start = System.currentTimeMillis();
var logger = PrintLogger.STDOUT_LOGGER;
var backoff =
long start = System.currentTimeMillis();
PrintLogger logger = PrintLogger.STDOUT_LOGGER;
BackoffWrapper backoff =
new BackoffWrapper(
logger,
10L,
Expand All @@ -45,10 +45,10 @@ void alwaysFailingAction() {

@Test
void eventuallySucceedingAction() {
var start = System.currentTimeMillis();
var count = new AtomicInteger(0);
var logger = PrintLogger.STDOUT_LOGGER;
var backoff =
long start = System.currentTimeMillis();
AtomicInteger count = new AtomicInteger(0);
PrintLogger logger = PrintLogger.STDOUT_LOGGER;
BackoffWrapper backoff =
new BackoffWrapper(
logger,
10L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.redhat.insights.InsightsException;
import com.redhat.insights.config.InsightsConfiguration;
import com.redhat.insights.http.BackoffWrapper;
import com.redhat.insights.http.InsightsHttpClient;
import com.redhat.insights.logging.InsightsLogger;
import com.redhat.insights.reports.InsightsReport;
Expand Down
Loading