Skip to content

Commit b1fa973

Browse files
committed
fix(java): bound autoscaled workers by their pool max
Encode the autoscaler's maxWorkers as the in-flight cap when autoscaling; otherwise an autoscaled worker (concurrency == 0) stayed unbounded.
1 parent 22ea967 commit b1fa973

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • sdks/java/src/main/java/org/byteveda/taskito/worker

sdks/java/src/main/java/org/byteveda/taskito/worker/Worker.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,12 @@ private String encodeOptions() {
424424
if (batchSize != null) {
425425
options.put("batchSize", batchSize);
426426
}
427-
// Only a fixed-size pool has a bounded parallelism to cap in-flight
428-
// dispatch against; a cached pool (concurrency == 0) stays unbounded.
429-
if (concurrency > 0) {
427+
// Cap in-flight dispatch by the pool's execution ceiling: the
428+
// autoscaler's max when autoscaling, otherwise a fixed pool's size.
429+
// A plain cached pool (concurrency == 0, no autoscale) stays unbounded.
430+
if (autoscale != null) {
431+
options.put("concurrency", autoscale.maxWorkers());
432+
} else if (concurrency > 0) {
430433
options.put("concurrency", concurrency);
431434
}
432435
if (!taskPolicies.isEmpty() || !taskCircuitBreakers.isEmpty()) {

0 commit comments

Comments
 (0)