Skip to content

Commit 64a043e

Browse files
committed
refactor: enable ExecutorService configuration, add doc
1 parent 67076c8 commit 64a043e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ExecutorServiceManager.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,26 @@ public ExecutorService workflowExecutorService() {
7070
return workflowExecutor;
7171
}
7272

73+
/**
74+
* Runs the specified I/O-bound task and waits for its completion using the ExecutorService
75+
* provided by {@link #workflowExecutorService()}
76+
*
77+
* @param task task to run concurrently
78+
*/
7379
public static void executeAndWaitForCompletion(Runnable task) {
80+
executeAndWaitForCompletion(task, instance().workflowExecutorService());
81+
}
82+
83+
/**
84+
* Executes the specified I/O-bound task using the specified ExecutorService and waits for its
85+
* completion for at most {@link #terminationTimeoutSeconds} seconds.
86+
*
87+
* @param task task to run concurrently
88+
* @param executor ExecutorService used to run the task
89+
*/
90+
public static void executeAndWaitForCompletion(Runnable task, ExecutorService executor) {
7491
try {
75-
instance().workflowExecutorService().submit(task)
76-
.get(instance().terminationTimeoutSeconds, TimeUnit.SECONDS);
92+
executor.submit(task).get(instance().terminationTimeoutSeconds, TimeUnit.SECONDS);
7793
} catch (InterruptedException | ExecutionException | TimeoutException e) {
7894
throw new OperatorException("Couldn't execute task", e);
7995
}

0 commit comments

Comments
 (0)