Skip to content

Commit

Permalink
Retry topic verification (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 authored Feb 13, 2025
1 parent f3b181b commit e8a9d6e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build-and-publish:
name: Java Gradle
uses: bakdata/ci-templates/.github/workflows/java-gradle-library.yaml@1.56.0
uses: bakdata/ci-templates/.github/workflows/java-gradle-library.yaml@1.62.0
with:
java-version: 17
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
java-gradle-release:
name: Java Gradle
uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.56.0
uses: bakdata/ci-templates/.github/workflows/java-gradle-release.yaml@1.62.0
with:
java-version: 17
release-type: "${{ inputs.release-type }}"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 4 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
1 change: 1 addition & 0 deletions streams-bootstrap-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
version = "2.0.16"
)
implementation(group = "org.jooq", name = "jool", version = "0.9.15")
implementation(group = "io.github.resilience4j", name = "resilience4j-retry", version = "1.7.1")

val junitVersion: String by project
testRuntimeOnly(group = "org.junit.jupiter", name = "junit-jupiter-engine", version = junitVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import static java.util.Collections.emptyMap;

import io.github.resilience4j.retry.Retry;
import io.github.resilience4j.retry.RetryConfig;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -55,6 +57,12 @@
@Slf4j
public final class TopicClient implements AutoCloseable {

private static final RetryConfig RETRY_CONFIG = RetryConfig.<Boolean>custom()
.retryOnResult(result -> result)
.failAfterMaxAttempts(false)
.maxAttempts(3)
.waitDuration(Duration.ofSeconds(5L))
.build();
private final @NonNull Admin adminClient;
private final @NonNull Duration timeout;

Expand Down Expand Up @@ -142,7 +150,9 @@ public void deleteTopic(final String topicName) {
} catch (final TimeoutException ex) {
throw failedToDeleteTopic(topicName, ex);
}
if (this.exists(topicName)) {
final Retry retry = Retry.of("topic-deleted", RETRY_CONFIG);
final boolean exists = Retry.decorateSupplier(retry, () -> this.exists(topicName)).get();
if (exists) {
throw new IllegalStateException(String.format("Deletion of topic %s failed", topicName));
}
}
Expand Down Expand Up @@ -259,7 +269,9 @@ public void createTopic(final String topicName, final TopicSettings settings, fi
} catch (final TimeoutException ex) {
throw failedToCreateTopic(topicName, ex);
}
if (!this.exists(topicName)) {
final Retry retry = Retry.of("topic-exists", RETRY_CONFIG);
final boolean doesNotExist = Retry.decorateSupplier(retry, () -> !this.exists(topicName)).get();
if (doesNotExist) {
throw new IllegalStateException(String.format("Creation of topic %s failed", topicName));
}
}
Expand Down

0 comments on commit e8a9d6e

Please sign in to comment.