mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 02:14:38 -05:00
fix(core): deprecate Await util (#13369)
This reverts commit 9fa94deba9.
This commit is contained in:
@@ -160,7 +160,7 @@ public class RunnerUtils {
|
|||||||
executionEmitter.run();
|
executionEmitter.run();
|
||||||
|
|
||||||
if (duration == null) {
|
if (duration == null) {
|
||||||
Await.untilWithSleepInterval(() -> receive.get() != null, Duration.ofMillis(10));
|
Await.until(() -> receive.get() != null, Duration.ofMillis(10));
|
||||||
} else {
|
} else {
|
||||||
Await.until(() -> receive.get() != null, Duration.ofMillis(10), duration);
|
Await.until(() -> receive.get() != null, Duration.ofMillis(10), duration);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,18 +6,18 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link org.awaitility.Awaitility} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public class Await {
|
public class Await {
|
||||||
private static final Duration defaultSleep = Duration.ofMillis(100);
|
private static final Duration defaultSleep = Duration.ofMillis(100);
|
||||||
|
|
||||||
public static void until(BooleanSupplier condition) {
|
public static void until(BooleanSupplier condition) {
|
||||||
Await.untilWithSleepInterval(condition, null);
|
Await.until(condition, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void untilWithTimeout(BooleanSupplier condition, Duration timeout) throws TimeoutException {
|
public static void until(BooleanSupplier condition, Duration sleep) {
|
||||||
until(condition, null, timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void untilWithSleepInterval(BooleanSupplier condition, Duration sleep) {
|
|
||||||
if (sleep == null) {
|
if (sleep == null) {
|
||||||
sleep = defaultSleep;
|
sleep = defaultSleep;
|
||||||
}
|
}
|
||||||
@@ -78,10 +78,10 @@ public class Await {
|
|||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T untilWithSleepInterval(Supplier<T> supplier, Duration sleep) {
|
public static <T> T until(Supplier<T> supplier, Duration sleep) {
|
||||||
AtomicReference<T> result = new AtomicReference<>();
|
AtomicReference<T> result = new AtomicReference<>();
|
||||||
|
|
||||||
Await.untilWithSleepInterval(untilSupplier(supplier, result), sleep);
|
Await.until(untilSupplier(supplier, result), sleep);
|
||||||
|
|
||||||
return result.get();
|
return result.get();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1094,7 +1094,7 @@ public class DefaultWorker implements Worker {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// wait for task completion
|
// wait for task completion
|
||||||
Await.untilWithSleepInterval(
|
Await.until(
|
||||||
() -> {
|
() -> {
|
||||||
ServiceState serviceState = shutdownState.get();
|
ServiceState serviceState = shutdownState.get();
|
||||||
if (serviceState == TERMINATED_FORCED || serviceState == TERMINATED_GRACEFULLY) {
|
if (serviceState == TERMINATED_FORCED || serviceState == TERMINATED_GRACEFULLY) {
|
||||||
|
|||||||
Reference in New Issue
Block a user