Skip to content

Commit 5978835

Browse files
Set deploymentOptions on other types of poll requests (#2555)
1 parent a25f6ba commit 5978835

File tree

6 files changed

+37
-32
lines changed

6 files changed

+37
-32
lines changed

temporal-sdk/src/main/java/io/temporal/internal/worker/ActivityPollTask.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.concurrent.atomic.AtomicInteger;
2121
import java.util.function.Supplier;
2222
import javax.annotation.Nonnull;
23-
import javax.annotation.Nullable;
2423
import org.slf4j.Logger;
2524
import org.slf4j.LoggerFactory;
2625

@@ -39,8 +38,7 @@ public ActivityPollTask(
3938
@Nonnull String namespace,
4039
@Nonnull String taskQueue,
4140
@Nonnull String identity,
42-
@Nullable String buildId,
43-
boolean useBuildIdForVersioning,
41+
@Nonnull WorkerVersioningOptions versioningOptions,
4442
double activitiesPerSecond,
4543
@Nonnull TrackingSlotSupplier<ActivitySlotInfo> slotSupplier,
4644
@Nonnull Scope metricsScope,
@@ -61,13 +59,18 @@ public ActivityPollTask(
6159
.build());
6260
}
6361

64-
if (serverCapabilities.get().getBuildIdBasedVersioning()) {
62+
if (versioningOptions.getWorkerDeploymentOptions() != null) {
63+
pollRequest.setDeploymentOptions(
64+
WorkerVersioningProtoUtils.deploymentOptionsToProto(
65+
versioningOptions.getWorkerDeploymentOptions()));
66+
} else if (serverCapabilities.get().getBuildIdBasedVersioning()) {
6567
pollRequest.setWorkerVersionCapabilities(
6668
WorkerVersionCapabilities.newBuilder()
67-
.setBuildId(buildId)
68-
.setUseVersioning(useBuildIdForVersioning)
69+
.setBuildId(versioningOptions.getBuildId())
70+
.setUseVersioning(versioningOptions.isUsingVersioning())
6971
.build());
7072
}
73+
7174
this.pollRequest = pollRequest.build();
7275
}
7376

temporal-sdk/src/main/java/io/temporal/internal/worker/ActivityWorker.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public boolean start() {
9999
namespace,
100100
taskQueue,
101101
options.getIdentity(),
102-
options.getBuildId(),
103-
options.isUsingBuildIdForVersioning(),
102+
options.getWorkerVersioningOptions(),
104103
taskQueueActivitiesPerSecond,
105104
this.slotSupplier,
106105
workerMetricsScope,
@@ -118,8 +117,7 @@ public boolean start() {
118117
namespace,
119118
taskQueue,
120119
options.getIdentity(),
121-
options.getBuildId(),
122-
options.isUsingBuildIdForVersioning(),
120+
options.getWorkerVersioningOptions(),
123121
taskQueueActivitiesPerSecond,
124122
this.slotSupplier,
125123
workerMetricsScope,

temporal-sdk/src/main/java/io/temporal/internal/worker/AsyncActivityPollTask.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.concurrent.atomic.AtomicInteger;
2626
import java.util.function.Supplier;
2727
import javax.annotation.Nonnull;
28-
import javax.annotation.Nullable;
2928
import org.slf4j.Logger;
3029
import org.slf4j.LoggerFactory;
3130

@@ -45,8 +44,7 @@ public AsyncActivityPollTask(
4544
@Nonnull String namespace,
4645
@Nonnull String taskQueue,
4746
@Nonnull String identity,
48-
@Nullable String buildId,
49-
boolean useBuildIdForVersioning,
47+
@Nonnull WorkerVersioningOptions versioningOptions,
5048
double activitiesPerSecond,
5149
@Nonnull TrackingSlotSupplier<ActivitySlotInfo> slotSupplier,
5250
@Nonnull Scope metricsScope,
@@ -67,11 +65,15 @@ public AsyncActivityPollTask(
6765
.build());
6866
}
6967

70-
if (serverCapabilities.get().getBuildIdBasedVersioning()) {
68+
if (versioningOptions.getWorkerDeploymentOptions() != null) {
69+
pollRequest.setDeploymentOptions(
70+
WorkerVersioningProtoUtils.deploymentOptionsToProto(
71+
versioningOptions.getWorkerDeploymentOptions()));
72+
} else if (serverCapabilities.get().getBuildIdBasedVersioning()) {
7173
pollRequest.setWorkerVersionCapabilities(
7274
WorkerVersionCapabilities.newBuilder()
73-
.setBuildId(buildId)
74-
.setUseVersioning(useBuildIdForVersioning)
75+
.setBuildId(versioningOptions.getBuildId())
76+
.setUseVersioning(versioningOptions.isUsingVersioning())
7577
.build());
7678
}
7779
this.pollRequest = pollRequest.build();

temporal-sdk/src/main/java/io/temporal/internal/worker/AsyncNexusPollTask.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.concurrent.atomic.AtomicInteger;
2424
import java.util.function.Supplier;
2525
import javax.annotation.Nonnull;
26-
import javax.annotation.Nullable;
2726
import org.slf4j.Logger;
2827
import org.slf4j.LoggerFactory;
2928

@@ -43,8 +42,7 @@ public AsyncNexusPollTask(
4342
@Nonnull String namespace,
4443
@Nonnull String taskQueue,
4544
@Nonnull String identity,
46-
@Nullable String buildId,
47-
boolean useBuildIdForVersioning,
45+
@Nonnull WorkerVersioningOptions versioningOptions,
4846
@Nonnull Scope metricsScope,
4947
@Nonnull Supplier<GetSystemInfoResponse.Capabilities> serverCapabilities,
5048
TrackingSlotSupplier<?> slotSupplier) {
@@ -58,11 +56,15 @@ public AsyncNexusPollTask(
5856
.setIdentity(identity)
5957
.setTaskQueue(TaskQueue.newBuilder().setName(taskQueue));
6058

61-
if (serverCapabilities.get().getBuildIdBasedVersioning()) {
59+
if (versioningOptions.getWorkerDeploymentOptions() != null) {
60+
pollRequest.setDeploymentOptions(
61+
WorkerVersioningProtoUtils.deploymentOptionsToProto(
62+
versioningOptions.getWorkerDeploymentOptions()));
63+
} else if (serverCapabilities.get().getBuildIdBasedVersioning()) {
6264
pollRequest.setWorkerVersionCapabilities(
6365
WorkerVersionCapabilities.newBuilder()
64-
.setBuildId(buildId)
65-
.setUseVersioning(useBuildIdForVersioning)
66+
.setBuildId(versioningOptions.getBuildId())
67+
.setUseVersioning(versioningOptions.isUsingVersioning())
6668
.build());
6769
}
6870
this.pollRequest = pollRequest.build();

temporal-sdk/src/main/java/io/temporal/internal/worker/NexusPollTask.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.util.concurrent.atomic.AtomicInteger;
1818
import java.util.function.Supplier;
1919
import javax.annotation.Nonnull;
20-
import javax.annotation.Nullable;
2120
import org.slf4j.Logger;
2221
import org.slf4j.LoggerFactory;
2322

@@ -36,8 +35,7 @@ public NexusPollTask(
3635
@Nonnull String namespace,
3736
@Nonnull String taskQueue,
3837
@Nonnull String identity,
39-
@Nullable String buildId,
40-
boolean useBuildIdForVersioning,
38+
@Nonnull WorkerVersioningOptions versioningOptions,
4139
@Nonnull TrackingSlotSupplier<NexusSlotInfo> slotSupplier,
4240
@Nonnull Scope metricsScope,
4341
@Nonnull Supplier<GetSystemInfoResponse.Capabilities> serverCapabilities) {
@@ -51,11 +49,15 @@ public NexusPollTask(
5149
.setIdentity(identity)
5250
.setTaskQueue(TaskQueue.newBuilder().setName(taskQueue));
5351

54-
if (serverCapabilities.get().getBuildIdBasedVersioning()) {
52+
if (versioningOptions.getWorkerDeploymentOptions() != null) {
53+
pollRequest.setDeploymentOptions(
54+
WorkerVersioningProtoUtils.deploymentOptionsToProto(
55+
versioningOptions.getWorkerDeploymentOptions()));
56+
} else if (serverCapabilities.get().getBuildIdBasedVersioning()) {
5557
pollRequest.setWorkerVersionCapabilities(
5658
WorkerVersionCapabilities.newBuilder()
57-
.setBuildId(buildId)
58-
.setUseVersioning(useBuildIdForVersioning)
59+
.setBuildId(versioningOptions.getBuildId())
60+
.setUseVersioning(versioningOptions.isUsingVersioning())
5961
.build());
6062
}
6163
this.pollRequest = pollRequest.build();

temporal-sdk/src/main/java/io/temporal/internal/worker/NexusWorker.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ public boolean start() {
9696
namespace,
9797
taskQueue,
9898
options.getIdentity(),
99-
options.getBuildId(),
100-
options.isUsingBuildIdForVersioning(),
99+
options.getWorkerVersioningOptions(),
101100
workerMetricsScope,
102101
service.getServerCapabilities(),
103102
this.slotSupplier),
@@ -113,8 +112,7 @@ public boolean start() {
113112
namespace,
114113
taskQueue,
115114
options.getIdentity(),
116-
options.getBuildId(),
117-
options.isUsingBuildIdForVersioning(),
115+
options.getWorkerVersioningOptions(),
118116
this.slotSupplier,
119117
workerMetricsScope,
120118
service.getServerCapabilities()),

0 commit comments

Comments
 (0)