Skip to content

Commit

Permalink
feat(7678): add pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
pipinet committed Jan 10, 2024
1 parent 9e443b8 commit 24b9ea9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lang/src/main/java/com/qwlabs/lang/QueueWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private boolean execute(C context, int runs) {
stopWatch.start("work");
executeBeforeEach(context, element);
onWork.accept(context, element);
executeAfterEach(context, element);
} catch (Exception e) {
boolean shouldContinue = isContinue(context, element, e);
executeOnFailed(context, element, e);
Expand All @@ -118,7 +119,6 @@ private boolean execute(C context, int runs) {
return false;
}
} finally {
executeAfterEach(context, element);
stopWatch.stop();
}
if (Objects.isNull(spinDuration)) {
Expand All @@ -129,8 +129,8 @@ private boolean execute(C context, int runs) {

private boolean isOutOfMaxRuns(int runs) {
return Optional.ofNullable(maxRuns)
.map(mr -> mr < runs)
.orElse(false);
.map(mr -> mr < runs)
.orElse(false);
}

private void spin() {
Expand All @@ -149,9 +149,9 @@ private void spin() {

private boolean isContinue(C context, E element, Exception e) {
return Objects.nonNull(element)
&& Optional.ofNullable(continueWhen)
.map(f -> f.test(context, element, e))
.orElse(true);
&& Optional.ofNullable(continueWhen)
.map(f -> f.test(context, element, e))
.orElse(true);
}

@FunctionalInterface
Expand Down

0 comments on commit 24b9ea9

Please sign in to comment.