@@ -64,6 +64,7 @@ public static final class Builder {
6464 private Duration defaultHeartbeatThrottleInterval ;
6565 private Duration stickyQueueScheduleToStartTimeout ;
6666 private boolean disableEagerExecution ;
67+ private int maxConcurrentEagerActivityExecutionSize ;
6768 private String buildId ;
6869 private boolean useBuildIdForVersioning ;
6970 private Duration stickyTaskQueueDrainTimeout ;
@@ -109,6 +110,7 @@ private Builder(WorkerOptions o) {
109110 this .defaultHeartbeatThrottleInterval = o .defaultHeartbeatThrottleInterval ;
110111 this .stickyQueueScheduleToStartTimeout = o .stickyQueueScheduleToStartTimeout ;
111112 this .disableEagerExecution = o .disableEagerExecution ;
113+ this .maxConcurrentEagerActivityExecutionSize = o .maxConcurrentEagerActivityExecutionSize ;
112114 this .useBuildIdForVersioning = o .useBuildIdForVersioning ;
113115 this .buildId = o .buildId ;
114116 this .stickyTaskQueueDrainTimeout = o .stickyTaskQueueDrainTimeout ;
@@ -400,6 +402,19 @@ public Builder setDisableEagerExecution(boolean disableEagerExecution) {
400402 return this ;
401403 }
402404
405+ /**
406+ * Sets the maximum number of eager activities that can be running concurrently.
407+ *
408+ * <p>When nonzero, eager activity execution will not be requested if it would cause the number
409+ * of running eager activities to exceed this value. The default of zero means unlimited and
410+ * therefore only bound by the activity slot supplier.
411+ */
412+ public Builder setMaxConcurrentEagerActivityExecutionSize (
413+ int maxConcurrentEagerActivityExecutionSize ) {
414+ this .maxConcurrentEagerActivityExecutionSize = maxConcurrentEagerActivityExecutionSize ;
415+ return this ;
416+ }
417+
403418 /**
404419 * Opts the worker in to the Build-ID-based versioning feature. This ensures that the worker
405420 * will only receive tasks which it is compatible with.
@@ -623,6 +638,7 @@ public WorkerOptions build() {
623638 defaultHeartbeatThrottleInterval ,
624639 stickyQueueScheduleToStartTimeout ,
625640 disableEagerExecution ,
641+ maxConcurrentEagerActivityExecutionSize ,
626642 useBuildIdForVersioning ,
627643 buildId ,
628644 stickyTaskQueueDrainTimeout ,
@@ -647,6 +663,9 @@ public WorkerOptions validateAndBuildWithDefaults() {
647663 maxWorkerActivitiesPerSecond >= 0 , "negative maxActivitiesPerSecond" );
648664 Preconditions .checkState (
649665 maxConcurrentActivityExecutionSize >= 0 , "negative maxConcurrentActivityExecutionSize" );
666+ Preconditions .checkState (
667+ maxConcurrentEagerActivityExecutionSize >= 0 ,
668+ "negative maxConcurrentEagerActivityExecutionSize" );
650669 Preconditions .checkState (
651670 maxConcurrentWorkflowTaskExecutionSize >= 0 ,
652671 "negative maxConcurrentWorkflowTaskExecutionSize" );
@@ -758,6 +777,7 @@ public WorkerOptions validateAndBuildWithDefaults() {
758777 ? DEFAULT_STICKY_SCHEDULE_TO_START_TIMEOUT
759778 : stickyQueueScheduleToStartTimeout ,
760779 disableEagerExecution ,
780+ maxConcurrentEagerActivityExecutionSize ,
761781 useBuildIdForVersioning ,
762782 buildId ,
763783 stickyTaskQueueDrainTimeout == null
@@ -796,6 +816,7 @@ public WorkerOptions validateAndBuildWithDefaults() {
796816 private final Duration defaultHeartbeatThrottleInterval ;
797817 private final @ Nonnull Duration stickyQueueScheduleToStartTimeout ;
798818 private final boolean disableEagerExecution ;
819+ private final int maxConcurrentEagerActivityExecutionSize ;
799820 private final boolean useBuildIdForVersioning ;
800821 private final String buildId ;
801822 private final Duration stickyTaskQueueDrainTimeout ;
@@ -831,6 +852,7 @@ private WorkerOptions(
831852 Duration defaultHeartbeatThrottleInterval ,
832853 @ Nonnull Duration stickyQueueScheduleToStartTimeout ,
833854 boolean disableEagerExecution ,
855+ int maxConcurrentEagerActivityExecutionSize ,
834856 boolean useBuildIdForVersioning ,
835857 String buildId ,
836858 Duration stickyTaskQueueDrainTimeout ,
@@ -864,6 +886,7 @@ private WorkerOptions(
864886 this .defaultHeartbeatThrottleInterval = defaultHeartbeatThrottleInterval ;
865887 this .stickyQueueScheduleToStartTimeout = stickyQueueScheduleToStartTimeout ;
866888 this .disableEagerExecution = maxTaskQueueActivitiesPerSecond > 0 ? true : disableEagerExecution ;
889+ this .maxConcurrentEagerActivityExecutionSize = maxConcurrentEagerActivityExecutionSize ;
867890 this .useBuildIdForVersioning = useBuildIdForVersioning ;
868891 this .buildId = buildId ;
869892 this .stickyTaskQueueDrainTimeout = stickyTaskQueueDrainTimeout ;
@@ -989,6 +1012,10 @@ public boolean isEagerExecutionDisabled() {
9891012 return disableEagerExecution ;
9901013 }
9911014
1015+ public int getMaxConcurrentEagerActivityExecutionSize () {
1016+ return maxConcurrentEagerActivityExecutionSize ;
1017+ }
1018+
9921019 public boolean isUsingBuildIdForVersioning () {
9931020 return useBuildIdForVersioning ;
9941021 }
@@ -1070,6 +1097,7 @@ && compare(maxTaskQueueActivitiesPerSecond, that.maxTaskQueueActivitiesPerSecond
10701097 && localActivityWorkerOnly == that .localActivityWorkerOnly
10711098 && defaultDeadlockDetectionTimeout == that .defaultDeadlockDetectionTimeout
10721099 && disableEagerExecution == that .disableEagerExecution
1100+ && maxConcurrentEagerActivityExecutionSize == that .maxConcurrentEagerActivityExecutionSize
10731101 && useBuildIdForVersioning == that .useBuildIdForVersioning
10741102 && Objects .equals (workerTuner , that .workerTuner )
10751103 && Objects .equals (maxHeartbeatThrottleInterval , that .maxHeartbeatThrottleInterval )
@@ -1109,6 +1137,7 @@ public int hashCode() {
11091137 defaultHeartbeatThrottleInterval ,
11101138 stickyQueueScheduleToStartTimeout ,
11111139 disableEagerExecution ,
1140+ maxConcurrentEagerActivityExecutionSize ,
11121141 useBuildIdForVersioning ,
11131142 buildId ,
11141143 stickyTaskQueueDrainTimeout ,
@@ -1160,6 +1189,8 @@ public String toString() {
11601189 + stickyQueueScheduleToStartTimeout
11611190 + ", disableEagerExecution="
11621191 + disableEagerExecution
1192+ + ", maxConcurrentEagerActivityExecutionSize="
1193+ + maxConcurrentEagerActivityExecutionSize
11631194 + ", useBuildIdForVersioning="
11641195 + useBuildIdForVersioning
11651196 + ", buildId='"
0 commit comments