• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

temporalio / sdk-java / #175

pending completion
#175

push

github-actions

web-flow
Worker / Build Id versioning (#1786)

Implement new worker build id based versioning feature

236 of 236 new or added lines in 24 files covered. (100.0%)

18343 of 23697 relevant lines covered (77.41%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/temporal-sdk/src/main/java/io/temporal/workflow/ContinueAsNewOptions.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.workflow;
22

23
import io.temporal.common.SearchAttributes;
24
import io.temporal.common.VersioningIntent;
25
import io.temporal.common.context.ContextPropagator;
26
import java.time.Duration;
27
import java.util.List;
28
import java.util.Map;
29
import javax.annotation.Nullable;
30

31
/**
32
 * This class contain overrides for continueAsNew call. Every field can be null and it means that
33
 * the value of the option should be taken from the originating workflow run.
34
 */
35
public final class ContinueAsNewOptions {
36

37
  public static Builder newBuilder() {
38
    return new Builder();
1✔
39
  }
40

41
  public static Builder newBuilder(ContinueAsNewOptions options) {
42
    return new Builder(options);
×
43
  }
44

45
  public static ContinueAsNewOptions getDefaultInstance() {
46
    return DEFAULT_INSTANCE;
×
47
  }
48

49
  private static final ContinueAsNewOptions DEFAULT_INSTANCE;
50

51
  static {
52
    DEFAULT_INSTANCE = ContinueAsNewOptions.newBuilder().build();
1✔
53
  }
1✔
54

55
  public static final class Builder {
56

57
    private Duration workflowRunTimeout;
58
    private String taskQueue;
59
    private Duration workflowTaskTimeout;
60
    private Map<String, Object> memo;
61
    private Map<String, Object> searchAttributes;
62
    private SearchAttributes typedSearchAttributes;
63
    private List<ContextPropagator> contextPropagators;
64
    private VersioningIntent versioningIntent;
65

66
    private Builder() {}
67

68
    private Builder(ContinueAsNewOptions options) {
×
69
      if (options == null) {
×
70
        return;
×
71
      }
72
      this.workflowRunTimeout = options.workflowRunTimeout;
×
73
      this.taskQueue = options.taskQueue;
×
74
      this.workflowTaskTimeout = options.workflowTaskTimeout;
×
75
      this.memo = options.getMemo();
×
76
      this.searchAttributes = options.getSearchAttributes();
×
77
      this.typedSearchAttributes = options.getTypedSearchAttributes();
×
78
      this.contextPropagators = options.getContextPropagators();
×
79
      this.versioningIntent = options.versioningIntent;
×
80
    }
×
81

82
    public Builder setWorkflowRunTimeout(Duration workflowRunTimeout) {
83
      this.workflowRunTimeout = workflowRunTimeout;
×
84
      return this;
×
85
    }
86

87
    public Builder setTaskQueue(String taskQueue) {
88
      this.taskQueue = taskQueue;
1✔
89
      return this;
1✔
90
    }
91

92
    public Builder setWorkflowTaskTimeout(Duration workflowTaskTimeout) {
93
      this.workflowTaskTimeout = workflowTaskTimeout;
×
94
      return this;
×
95
    }
96

97
    public Builder setMemo(Map<String, Object> memo) {
98
      this.memo = memo;
1✔
99
      return this;
1✔
100
    }
101

102
    /**
103
     * @deprecated use {@link #setTypedSearchAttributes} instead.
104
     */
105
    @Deprecated
106
    public Builder setSearchAttributes(Map<String, Object> searchAttributes) {
107
      if (searchAttributes != null
×
108
          && !searchAttributes.isEmpty()
×
109
          && this.typedSearchAttributes != null) {
110
        throw new IllegalArgumentException(
×
111
            "Cannot have search attributes and typed search attributes");
112
      }
113
      this.searchAttributes = searchAttributes;
×
114
      return this;
×
115
    }
116

117
    public Builder setTypedSearchAttributes(SearchAttributes typedSearchAttributes) {
118
      if (typedSearchAttributes != null
1✔
119
          && searchAttributes != null
120
          && !searchAttributes.isEmpty()) {
×
121
        throw new IllegalArgumentException(
×
122
            "Cannot have typed search attributes and search attributes");
123
      }
124
      this.typedSearchAttributes = typedSearchAttributes;
1✔
125
      return this;
1✔
126
    }
127

128
    public Builder setContextPropagators(List<ContextPropagator> contextPropagators) {
129
      this.contextPropagators = contextPropagators;
×
130
      return this;
×
131
    }
132

133
    /**
134
     * Specifies whether this continued workflow should run on a worker with a compatible Build Id
135
     * or not. See the variants of {@link VersioningIntent}.
136
     */
137
    public Builder setVersioningIntent(VersioningIntent versioningIntent) {
138
      this.versioningIntent = versioningIntent;
×
139
      return this;
×
140
    }
141

142
    public ContinueAsNewOptions build() {
143
      return new ContinueAsNewOptions(
1✔
144
          workflowRunTimeout,
145
          taskQueue,
146
          workflowTaskTimeout,
147
          memo,
148
          searchAttributes,
149
          typedSearchAttributes,
150
          contextPropagators,
151
          versioningIntent);
152
    }
153
  }
154

155
  private final @Nullable Duration workflowRunTimeout;
156
  private final @Nullable String taskQueue;
157
  private final @Nullable Duration workflowTaskTimeout;
158
  private final @Nullable Map<String, Object> memo;
159
  private final @Nullable Map<String, Object> searchAttributes;
160
  private final @Nullable SearchAttributes typedSearchAttributes;
161
  private final @Nullable List<ContextPropagator> contextPropagators;
162
  private final @Nullable VersioningIntent versioningIntent;
163

164
  public ContinueAsNewOptions(
165
      @Nullable Duration workflowRunTimeout,
166
      @Nullable String taskQueue,
167
      @Nullable Duration workflowTaskTimeout,
168
      @Nullable Map<String, Object> memo,
169
      @Nullable Map<String, Object> searchAttributes,
170
      @Nullable SearchAttributes typedSearchAttributes,
171
      @Nullable List<ContextPropagator> contextPropagators,
172
      @Nullable VersioningIntent versioningIntent) {
1✔
173
    this.workflowRunTimeout = workflowRunTimeout;
1✔
174
    this.taskQueue = taskQueue;
1✔
175
    this.workflowTaskTimeout = workflowTaskTimeout;
1✔
176
    this.memo = memo;
1✔
177
    this.searchAttributes = searchAttributes;
1✔
178
    this.typedSearchAttributes = typedSearchAttributes;
1✔
179
    this.contextPropagators = contextPropagators;
1✔
180
    this.versioningIntent = versioningIntent;
1✔
181
  }
1✔
182

183
  public @Nullable Duration getWorkflowRunTimeout() {
184
    return workflowRunTimeout;
1✔
185
  }
186

187
  public @Nullable String getTaskQueue() {
188
    return taskQueue;
1✔
189
  }
190

191
  public @Nullable Duration getWorkflowTaskTimeout() {
192
    return workflowTaskTimeout;
1✔
193
  }
194

195
  public @Nullable Map<String, Object> getMemo() {
196
    return memo;
1✔
197
  }
198

199
  /**
200
   * @deprecated use {@link #getSearchAttributes} instead.
201
   */
202
  @Deprecated
203
  public @Nullable Map<String, Object> getSearchAttributes() {
204
    return searchAttributes;
1✔
205
  }
206

207
  public @Nullable SearchAttributes getTypedSearchAttributes() {
208
    return typedSearchAttributes;
1✔
209
  }
210

211
  public @Nullable List<ContextPropagator> getContextPropagators() {
212
    return contextPropagators;
1✔
213
  }
214

215
  public @Nullable VersioningIntent getVersioningIntent() {
216
    return versioningIntent;
1✔
217
  }
218
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc