aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis/queue/QueueService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/trygvis/queue/QueueService.java')
-rw-r--r--src/main/java/io/trygvis/queue/QueueService.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/io/trygvis/queue/QueueService.java b/src/main/java/io/trygvis/queue/QueueService.java
index f4ce536..1c38f1f 100644
--- a/src/main/java/io/trygvis/queue/QueueService.java
+++ b/src/main/java/io/trygvis/queue/QueueService.java
@@ -12,15 +12,27 @@ public interface QueueService {
public static class TaskExecutionRequest {
public final long chunkSize;
public final boolean stopOnError;
+ public final Long interval;
+ public final boolean continueOnFullChunk;
// TODO: saveExceptions
public TaskExecutionRequest(long chunkSize, boolean stopOnError) {
- if (chunkSize <= 0) {
- throw new IllegalArgumentException("chunkSize has to be bigger than zero.");
- }
+ this(chunkSize, stopOnError, null, true);
+ }
+ private TaskExecutionRequest(long chunkSize, boolean stopOnError, Long interval, boolean continueOnFullChunk) {
this.chunkSize = chunkSize;
this.stopOnError = stopOnError;
+ this.interval = interval;
+ this.continueOnFullChunk = continueOnFullChunk;
+ }
+
+ public TaskExecutionRequest interval(long interval) {
+ return new TaskExecutionRequest(chunkSize, stopOnError, interval, continueOnFullChunk);
+ }
+
+ public TaskExecutionRequest continueOnFullChunk(boolean continueOnFullChunk) {
+ return new TaskExecutionRequest(chunkSize, stopOnError, interval, continueOnFullChunk);
}
@Override
@@ -30,5 +42,13 @@ public interface QueueService {
", stopOnError=" + stopOnError +
'}';
}
+
+ public long interval(Queue queue) {
+ if (interval != null) {
+ return interval;
+ }
+
+ return queue.interval;
+ }
}
}