88import org .jspecify .annotations .Nullable ;
99
1010import java .util .Map ;
11+ import java .util .concurrent .CompletableFuture ;
12+ import java .util .concurrent .Executor ;
13+ import java .util .concurrent .ForkJoinPool ;
1114
1215/**
1316 * Defines the contract for processing and executing Python scripts, acting as a bridge between
3235 * @since 1.0.0
3336 */
3437public interface PythonProcessor {
38+ default CompletableFuture <Void > processAsync (String script ) {
39+ return this .processAsync (script , Map .of ());
40+ }
41+
42+ default CompletableFuture <Void > processAsync (PythonScript script ) {
43+ return this .processAsync (script , Map .of ());
44+ }
45+
46+ default CompletableFuture <Void > processAsync (String script , Map <String , Object > arguments ) {
47+ return this .processAsync (script , arguments , ForkJoinPool .commonPool ());
48+ }
49+
50+ default CompletableFuture <Void > processAsync (PythonScript script , Map <String , Object > arguments ) {
51+ return this .processAsync (script , arguments , ForkJoinPool .commonPool ());
52+ }
53+
54+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (String script , @ Nullable Class <? extends R > resultClass ) {
55+ return this .processAsync (script , resultClass , Map .of ());
56+ }
57+
58+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (PythonScript script , @ Nullable Class <? extends R > resultClass ) {
59+ return this .processAsync (script , resultClass , Map .of ());
60+ }
61+
62+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (String script , @ Nullable Class <? extends R > resultClass , Map <String , Object > arguments ) {
63+ return this .processAsync (script , resultClass , arguments , ForkJoinPool .commonPool ());
64+ }
65+
66+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (PythonScript script , @ Nullable Class <? extends R > resultClass , Map <String , Object > arguments ) {
67+ return this .processAsync (script , resultClass , arguments , ForkJoinPool .commonPool ());
68+ }
69+
70+ default CompletableFuture <Void > processAsync (String script , Executor executor ) {
71+ return this .processAsync (script , Map .of (), executor );
72+ }
73+
74+ default CompletableFuture <Void > processAsync (PythonScript script , Executor executor ) {
75+ return this .processAsync (script , Map .of (), executor );
76+ }
77+
78+ default CompletableFuture <Void > processAsync (String script , Map <String , Object > arguments , Executor executor ) {
79+ return CompletableFuture .runAsync (() -> this .process (script , arguments ), executor );
80+ }
81+
82+ default CompletableFuture <Void > processAsync (PythonScript script , Map <String , Object > arguments , Executor executor ) {
83+ return CompletableFuture .runAsync (() -> this .process (script , arguments ), executor );
84+ }
85+
86+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (String script , @ Nullable Class <? extends R > resultClass , Executor executor ) {
87+ return this .processAsync (script , resultClass , Map .of (), executor );
88+ }
89+
90+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (PythonScript script , @ Nullable Class <? extends R > resultClass , Executor executor ) {
91+ return this .processAsync (script , resultClass , Map .of (), executor );
92+ }
93+
94+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (String script , @ Nullable Class <? extends R > resultClass , Map <String , Object > arguments , Executor executor ) {
95+ PythonScript pythonScript = new PythonScript (script );
96+ return this .processAsync (pythonScript , resultClass , arguments , executor );
97+ }
98+
99+ default <R > CompletableFuture <PythonExecutionResponse <R >> processAsync (PythonScript script , @ Nullable Class <? extends R > resultClass , Map <String , Object > arguments , Executor executor ) {
100+ return CompletableFuture .supplyAsync (() -> this .process (script , resultClass , arguments ), executor );
101+ }
102+
35103 /**
36104 * Processes and executes a Python script without additional arguments or body mapping.
37105 *
38106 * @param script non-{@code null} Python script to execute
39107 */
40- default PythonExecutionResponse <? > process (String script ) {
108+ default PythonExecutionResponse <Void > process (String script ) {
41109 return this .process (script , null , Map .of ());
42110 }
43111
@@ -46,7 +114,7 @@ default PythonExecutionResponse<?> process(String script) {
46114 *
47115 * @param script non-{@code null} Python script to execute
48116 */
49- default PythonExecutionResponse <? > process (PythonScript script ) {
117+ default PythonExecutionResponse <Void > process (PythonScript script ) {
50118 return this .process (script , null , Map .of ());
51119 }
52120
@@ -56,7 +124,7 @@ default PythonExecutionResponse<?> process(PythonScript script) {
56124 * @param script non-{@code null} Python script to execute
57125 * @param arguments a map of arguments accessible to resolvers during preprocessing
58126 */
59- default PythonExecutionResponse <? > process (String script , Map <String , Object > arguments ) {
127+ default PythonExecutionResponse <Void > process (String script , Map <String , Object > arguments ) {
60128 return this .process (script , null , arguments );
61129 }
62130
@@ -66,7 +134,7 @@ default PythonExecutionResponse<?> process(String script, Map<String, Object> ar
66134 * @param script non-{@code null} Python script to execute
67135 * @param arguments a map of arguments accessible to resolvers during preprocessing
68136 */
69- default PythonExecutionResponse <? > process (PythonScript script , Map <String , Object > arguments ) {
137+ default PythonExecutionResponse <Void > process (PythonScript script , Map <String , Object > arguments ) {
70138 return this .process (script , null , arguments );
71139 }
72140
0 commit comments