20
20
21
21
package io .temporal .worker ;
22
22
23
+ import com .google .common .annotations .VisibleForTesting ;
23
24
import com .google .common .base .Preconditions ;
24
25
import io .temporal .common .Experimental ;
25
26
import io .temporal .common .interceptors .WorkerInterceptor ;
26
27
import java .time .Duration ;
28
+ import java .util .concurrent .ExecutorService ;
27
29
import javax .annotation .Nullable ;
28
30
29
31
public class WorkerFactoryOptions {
@@ -57,6 +59,7 @@ public static class Builder {
57
59
private WorkerInterceptor [] workerInterceptors ;
58
60
private boolean enableLoggingInReplay ;
59
61
private boolean usingVirtualWorkflowThreads ;
62
+ private ExecutorService overrideLocalActivityTaskExecutor ;
60
63
61
64
private Builder () {}
62
65
@@ -71,6 +74,7 @@ private Builder(WorkerFactoryOptions options) {
71
74
this .workerInterceptors = options .workerInterceptors ;
72
75
this .enableLoggingInReplay = options .enableLoggingInReplay ;
73
76
this .usingVirtualWorkflowThreads = options .usingVirtualWorkflowThreads ;
77
+ this .overrideLocalActivityTaskExecutor = options .overrideLocalActivityTaskExecutor ;
74
78
}
75
79
76
80
/**
@@ -143,6 +147,14 @@ public Builder setWorkflowHostLocalPollThreadCount(int workflowHostLocalPollThre
143
147
return this ;
144
148
}
145
149
150
+ /** For internal use only. Overrides the local activity task ExecutorService. */
151
+ @ VisibleForTesting
152
+ Builder setOverrideLocalActivityTaskExecutor (
153
+ ExecutorService overrideLocalActivityTaskExecutor ) {
154
+ this .overrideLocalActivityTaskExecutor = overrideLocalActivityTaskExecutor ;
155
+ return this ;
156
+ }
157
+
146
158
public WorkerFactoryOptions build () {
147
159
return new WorkerFactoryOptions (
148
160
workflowCacheSize ,
@@ -151,6 +163,7 @@ public WorkerFactoryOptions build() {
151
163
workerInterceptors ,
152
164
enableLoggingInReplay ,
153
165
usingVirtualWorkflowThreads ,
166
+ overrideLocalActivityTaskExecutor ,
154
167
false );
155
168
}
156
169
@@ -162,6 +175,7 @@ public WorkerFactoryOptions validateAndBuildWithDefaults() {
162
175
workerInterceptors == null ? new WorkerInterceptor [0 ] : workerInterceptors ,
163
176
enableLoggingInReplay ,
164
177
usingVirtualWorkflowThreads ,
178
+ overrideLocalActivityTaskExecutor ,
165
179
true );
166
180
}
167
181
}
@@ -172,6 +186,7 @@ public WorkerFactoryOptions validateAndBuildWithDefaults() {
172
186
private final WorkerInterceptor [] workerInterceptors ;
173
187
private final boolean enableLoggingInReplay ;
174
188
private final boolean usingVirtualWorkflowThreads ;
189
+ private final ExecutorService overrideLocalActivityTaskExecutor ;
175
190
176
191
private WorkerFactoryOptions (
177
192
int workflowCacheSize ,
@@ -180,6 +195,7 @@ private WorkerFactoryOptions(
180
195
WorkerInterceptor [] workerInterceptors ,
181
196
boolean enableLoggingInReplay ,
182
197
boolean usingVirtualWorkflowThreads ,
198
+ ExecutorService overrideLocalActivityTaskExecutor ,
183
199
boolean validate ) {
184
200
if (validate ) {
185
201
Preconditions .checkState (workflowCacheSize >= 0 , "negative workflowCacheSize" );
@@ -207,6 +223,7 @@ private WorkerFactoryOptions(
207
223
this .workerInterceptors = workerInterceptors ;
208
224
this .enableLoggingInReplay = enableLoggingInReplay ;
209
225
this .usingVirtualWorkflowThreads = usingVirtualWorkflowThreads ;
226
+ this .overrideLocalActivityTaskExecutor = overrideLocalActivityTaskExecutor ;
210
227
}
211
228
212
229
public int getWorkflowCacheSize () {
@@ -235,6 +252,16 @@ public boolean isUsingVirtualWorkflowThreads() {
235
252
return usingVirtualWorkflowThreads ;
236
253
}
237
254
255
+ /**
256
+ * For internal use only.
257
+ *
258
+ * @return the ExecutorService to use for local activity tasks, or null if the default should be
259
+ * used
260
+ */
261
+ ExecutorService getOverrideLocalActivityTaskExecutor () {
262
+ return overrideLocalActivityTaskExecutor ;
263
+ }
264
+
238
265
/**
239
266
* @deprecated not used anymore by JavaSDK, this value doesn't have any effect
240
267
*/
0 commit comments