From b767f562e52636776e8a23b6b10cca88f13f397e Mon Sep 17 00:00:00 2001 From: Ilia Voloshanovskii Date: Mon, 3 Jan 2022 18:24:55 +0400 Subject: [PATCH 1/5] Update license --- LICENSE | 2 +- .../java/io/github/pepperkit/retry/BackoffFunction.java | 6 ++++++ src/main/java/io/github/pepperkit/retry/CallableRetry.java | 6 ++++++ src/main/java/io/github/pepperkit/retry/Retry.java | 6 ++++++ .../github/pepperkit/retry/RetryInterruptedException.java | 6 ++++++ src/main/java/io/github/pepperkit/retry/RunnableRetry.java | 6 ++++++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index a9d48b9..555b604 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Artur Aukhatov +Copyright (c) 2022 Artur Aukhatov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/main/java/io/github/pepperkit/retry/BackoffFunction.java b/src/main/java/io/github/pepperkit/retry/BackoffFunction.java index f6d8408..064fb52 100644 --- a/src/main/java/io/github/pepperkit/retry/BackoffFunction.java +++ b/src/main/java/io/github/pepperkit/retry/BackoffFunction.java @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2022 PepperKit + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ package io.github.pepperkit.retry; import java.security.SecureRandom; diff --git a/src/main/java/io/github/pepperkit/retry/CallableRetry.java b/src/main/java/io/github/pepperkit/retry/CallableRetry.java index d3ae873..c062c3b 100644 --- a/src/main/java/io/github/pepperkit/retry/CallableRetry.java +++ b/src/main/java/io/github/pepperkit/retry/CallableRetry.java @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2022 PepperKit + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ package io.github.pepperkit.retry; public interface CallableRetry { diff --git a/src/main/java/io/github/pepperkit/retry/Retry.java b/src/main/java/io/github/pepperkit/retry/Retry.java index 0e4735a..c0672aa 100644 --- a/src/main/java/io/github/pepperkit/retry/Retry.java +++ b/src/main/java/io/github/pepperkit/retry/Retry.java @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2022 PepperKit + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ package io.github.pepperkit.retry; import java.time.Duration; diff --git a/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java b/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java index 1597667..98a2655 100644 --- a/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java +++ b/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2022 PepperKit + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ package io.github.pepperkit.retry; public class RetryInterruptedException extends RuntimeException { diff --git a/src/main/java/io/github/pepperkit/retry/RunnableRetry.java b/src/main/java/io/github/pepperkit/retry/RunnableRetry.java index ea5c9c2..1b44dbe 100644 --- a/src/main/java/io/github/pepperkit/retry/RunnableRetry.java +++ b/src/main/java/io/github/pepperkit/retry/RunnableRetry.java @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2022 PepperKit + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ package io.github.pepperkit.retry; public interface RunnableRetry { From 6eda3eee34f80365e2f0d68925edcb68d573a548 Mon Sep 17 00:00:00 2001 From: Ilia Voloshanovskii Date: Mon, 10 Jan 2022 12:39:41 +0400 Subject: [PATCH 2/5] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bffa164..1fd59d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .gradle .idea +build +.DS_Store \ No newline at end of file From 109851580f9e2677c1e3b74ca1349757d0ccccee Mon Sep 17 00:00:00 2001 From: Ilia Voloshanovskii Date: Mon, 10 Jan 2022 12:40:14 +0400 Subject: [PATCH 3/5] Update checkstyle version --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 3b80e2b..8febba0 100644 --- a/build.gradle +++ b/build.gradle @@ -51,9 +51,9 @@ test { } checkstyle { - toolVersion '8.42' + toolVersion '9.2.1' config project.resources.text - .fromUri(new URI("https://raw.githubusercontent.com/pepperkit/checkstyle/v1.0.0-8.45/checkstyle.xml")) + .fromUri(new URI("https://raw.githubusercontent.com/pepperkit/checkstyle/v1.0.2-9.2/checkstyle.xml")) } tasks.withType(Javadoc) { From ef8a7ba6d04dd7e875dcf11340e3ad984c0c6a69 Mon Sep 17 00:00:00 2001 From: Ilia Voloshanovskii Date: Mon, 10 Jan 2022 13:02:43 +0400 Subject: [PATCH 4/5] Update javadoc --- README.md | 2 +- .../io/github/pepperkit/retry/BackoffFunction.java | 13 +++++++++++++ .../io/github/pepperkit/retry/CallableRetry.java | 4 ++++ src/main/java/io/github/pepperkit/retry/Retry.java | 3 +++ .../pepperkit/retry/RetryInterruptedException.java | 3 +++ .../io/github/pepperkit/retry/RunnableRetry.java | 3 +++ 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b9f4bd0..bdde4ab 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ new BackoffFunction.Exponential(3); ``` #### Fixed -This is an elementary implementation, just return a constant value. +This is an elementary implementation, it just returns a constant value. ```text 3s -> 3s -> 3s -> 3s ``` diff --git a/src/main/java/io/github/pepperkit/retry/BackoffFunction.java b/src/main/java/io/github/pepperkit/retry/BackoffFunction.java index 064fb52..c4ff28c 100644 --- a/src/main/java/io/github/pepperkit/retry/BackoffFunction.java +++ b/src/main/java/io/github/pepperkit/retry/BackoffFunction.java @@ -9,11 +9,17 @@ import java.security.SecureRandom; import java.time.Duration; +/** + * The backoff function determines how much to wait between the retries. + */ @FunctionalInterface public interface BackoffFunction { Duration delay(int attempt, Duration delay); + /** + * An elementary implementation of a backoff function, just returns a constant value. + */ class Fixed implements BackoffFunction { public Fixed() { @@ -26,11 +32,15 @@ public Duration delay(int attempt, Duration delay) { } } + /** + * Exponential backoff function waits progressively longer intervals between subsequent retries. + */ class Exponential implements BackoffFunction { private static final int DEFAULT_FACTOR = 3; private final int factor; + public Exponential(int factor) { if (factor < 1) { throw new IllegalArgumentException("Factor must be greater than 1"); @@ -51,6 +61,9 @@ public Duration delay(int attempt, Duration delay) { } } + /** + * Randomized backoff algorithm implementation, each interval value is determined randomly. + */ class Randomized implements BackoffFunction { private final int bound; diff --git a/src/main/java/io/github/pepperkit/retry/CallableRetry.java b/src/main/java/io/github/pepperkit/retry/CallableRetry.java index c062c3b..4b52d40 100644 --- a/src/main/java/io/github/pepperkit/retry/CallableRetry.java +++ b/src/main/java/io/github/pepperkit/retry/CallableRetry.java @@ -6,6 +6,10 @@ */ package io.github.pepperkit.retry; +/** + * Callable version of a retry action. + * @param the type of returned value + */ public interface CallableRetry { /** diff --git a/src/main/java/io/github/pepperkit/retry/Retry.java b/src/main/java/io/github/pepperkit/retry/Retry.java index c0672aa..22f0131 100644 --- a/src/main/java/io/github/pepperkit/retry/Retry.java +++ b/src/main/java/io/github/pepperkit/retry/Retry.java @@ -14,6 +14,9 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +/** + * A static interface for the Retry library. + */ public final class Retry { private static final int DEFAULT_MAX_ATTEMPTS = 3; diff --git a/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java b/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java index 98a2655..268a8e1 100644 --- a/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java +++ b/src/main/java/io/github/pepperkit/retry/RetryInterruptedException.java @@ -6,6 +6,9 @@ */ package io.github.pepperkit.retry; +/** + * Exception, which occurs if retry attempt was interrupted. + */ public class RetryInterruptedException extends RuntimeException { private static final long serialVersionUID = 5443040601324416580L; diff --git a/src/main/java/io/github/pepperkit/retry/RunnableRetry.java b/src/main/java/io/github/pepperkit/retry/RunnableRetry.java index 1b44dbe..c5680d8 100644 --- a/src/main/java/io/github/pepperkit/retry/RunnableRetry.java +++ b/src/main/java/io/github/pepperkit/retry/RunnableRetry.java @@ -6,6 +6,9 @@ */ package io.github.pepperkit.retry; +/** + * Runnable version of a retry action. + */ public interface RunnableRetry { /** From 88976dab1e42388d9885bdc6a3bc249c5d1ebf7a Mon Sep 17 00:00:00 2001 From: Ilia Voloshanovskii Date: Mon, 10 Jan 2022 13:16:45 +0400 Subject: [PATCH 5/5] Update license file --- .gitignore | 2 +- LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1fd59d8..be04972 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .gradle .idea build -.DS_Store \ No newline at end of file +.DS_Store diff --git a/LICENSE b/LICENSE index 555b604..3b45d71 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Artur Aukhatov +Copyright (c) 2022 PepperKit Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal