Skip to content

Commit 645420f

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents ba37121 + e6872b9 commit 645420f

32 files changed

+979
-52
lines changed

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#Fri Nov 15 14:14:26 CET 2019
21
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
32
distributionBase=GRADLE_USER_HOME
43
distributionPath=wrapper/dists

src/main/java/com/uber/cadence/activity/ActivityOptions.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
import com.uber.cadence.common.MethodRetry;
2323
import com.uber.cadence.common.RetryOptions;
24+
import com.uber.cadence.context.ContextPropagator;
2425
import java.time.Duration;
26+
import java.util.List;
2527
import java.util.Objects;
2628

2729
/** Options used to configure how an activity is invoked. */
@@ -55,6 +57,7 @@ public static ActivityOptions merge(ActivityMethod a, MethodRetry r, ActivityOpt
5557
? o.getTaskList()
5658
: (a.taskList().isEmpty() ? null : a.taskList()))
5759
.setRetryOptions(RetryOptions.merge(r, o.getRetryOptions()))
60+
.setContextPropagators(o.getContextPropagators())
5861
.validateAndBuildWithDefaults();
5962
}
6063

@@ -72,6 +75,8 @@ public static final class Builder {
7275

7376
private RetryOptions retryOptions;
7477

78+
private List<ContextPropagator> contextPropagators;
79+
7580
public Builder() {}
7681

7782
/** Copy Builder fields from the options. */
@@ -85,6 +90,7 @@ public Builder(ActivityOptions options) {
8590
this.startToCloseTimeout = options.getStartToCloseTimeout();
8691
this.taskList = options.taskList;
8792
this.retryOptions = options.retryOptions;
93+
this.contextPropagators = options.contextPropagators;
8894
}
8995

9096
/**
@@ -143,14 +149,21 @@ public Builder setRetryOptions(RetryOptions retryOptions) {
143149
return this;
144150
}
145151

152+
/** ContextPropagators help propagate the context from the workflow to the activities */
153+
public Builder setContextPropagators(List<ContextPropagator> contextPropagators) {
154+
this.contextPropagators = contextPropagators;
155+
return this;
156+
}
157+
146158
public ActivityOptions build() {
147159
return new ActivityOptions(
148160
heartbeatTimeout,
149161
scheduleToCloseTimeout,
150162
scheduleToStartTimeout,
151163
startToCloseTimeout,
152164
taskList,
153-
retryOptions);
165+
retryOptions,
166+
contextPropagators);
154167
}
155168

156169
public ActivityOptions validateAndBuildWithDefaults() {
@@ -187,7 +200,8 @@ public ActivityOptions validateAndBuildWithDefaults() {
187200
roundUpToSeconds(scheduleToStart),
188201
roundUpToSeconds(startToClose),
189202
taskList,
190-
ro);
203+
ro,
204+
contextPropagators);
191205
}
192206
}
193207

@@ -203,13 +217,16 @@ public ActivityOptions validateAndBuildWithDefaults() {
203217

204218
private final RetryOptions retryOptions;
205219

220+
private final List<ContextPropagator> contextPropagators;
221+
206222
private ActivityOptions(
207223
Duration heartbeatTimeout,
208224
Duration scheduleToCloseTimeout,
209225
Duration scheduleToStartTimeout,
210226
Duration startToCloseTimeout,
211227
String taskList,
212-
RetryOptions retryOptions) {
228+
RetryOptions retryOptions,
229+
List<ContextPropagator> contextPropagators) {
213230
this.heartbeatTimeout = heartbeatTimeout;
214231
this.scheduleToCloseTimeout = scheduleToCloseTimeout;
215232
if (scheduleToCloseTimeout != null) {
@@ -229,6 +246,7 @@ private ActivityOptions(
229246
}
230247
this.taskList = taskList;
231248
this.retryOptions = retryOptions;
249+
this.contextPropagators = contextPropagators;
232250
}
233251

234252
public Duration getHeartbeatTimeout() {
@@ -255,6 +273,10 @@ public RetryOptions getRetryOptions() {
255273
return retryOptions;
256274
}
257275

276+
public List<ContextPropagator> getContextPropagators() {
277+
return contextPropagators;
278+
}
279+
258280
@Override
259281
public String toString() {
260282
return "ActivityOptions{"
@@ -271,6 +293,8 @@ public String toString() {
271293
+ '\''
272294
+ ", retryOptions="
273295
+ retryOptions
296+
+ ", contextPropagators"
297+
+ contextPropagators
274298
+ '}';
275299
}
276300

@@ -285,7 +309,8 @@ public boolean equals(Object o) {
285309
&& Objects.equals(scheduleToStartTimeout, that.scheduleToStartTimeout)
286310
&& Objects.equals(startToCloseTimeout, that.startToCloseTimeout)
287311
&& Objects.equals(taskList, that.taskList)
288-
&& Objects.equals(retryOptions, that.retryOptions);
312+
&& Objects.equals(retryOptions, that.retryOptions)
313+
&& Objects.equals(contextPropagators, that.contextPropagators);
289314
}
290315

291316
@Override
@@ -296,7 +321,8 @@ public int hashCode() {
296321
scheduleToStartTimeout,
297322
startToCloseTimeout,
298323
taskList,
299-
retryOptions);
324+
retryOptions,
325+
contextPropagators);
300326
}
301327

302328
static Duration mergeDuration(int annotationSeconds, Duration options) {

src/main/java/com/uber/cadence/client/WorkflowOptions.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import com.uber.cadence.common.CronSchedule;
3030
import com.uber.cadence.common.MethodRetry;
3131
import com.uber.cadence.common.RetryOptions;
32+
import com.uber.cadence.context.ContextPropagator;
3233
import com.uber.cadence.internal.common.OptionsUtils;
3334
import com.uber.cadence.workflow.WorkflowMethod;
3435
import java.time.Duration;
36+
import java.util.List;
3537
import java.util.Map;
3638
import java.util.Objects;
3739

@@ -63,6 +65,7 @@ public static WorkflowOptions merge(
6365
.setCronSchedule(OptionsUtils.merge(cronAnnotation, o.getCronSchedule(), String.class))
6466
.setMemo(o.getMemo())
6567
.setSearchAttributes(o.getSearchAttributes())
68+
.setContextPropagators(o.getContextPropagators())
6669
.validateBuildWithDefaults();
6770
}
6871

@@ -86,6 +89,8 @@ public static final class Builder {
8689

8790
private Map<String, Object> searchAttributes;
8891

92+
private List<ContextPropagator> contextPropagators;
93+
8994
public Builder() {}
9095

9196
public Builder(WorkflowOptions o) {
@@ -101,6 +106,7 @@ public Builder(WorkflowOptions o) {
101106
this.cronSchedule = o.cronSchedule;
102107
this.memo = o.memo;
103108
this.searchAttributes = o.searchAttributes;
109+
this.contextPropagators = o.contextPropagators;
104110
}
105111

106112
/**
@@ -197,6 +203,12 @@ public Builder setSearchAttributes(Map<String, Object> searchAttributes) {
197203
return this;
198204
}
199205

206+
/** Specifies the list of context propagators to use during this workflow. */
207+
public Builder setContextPropagators(List<ContextPropagator> contextPropagators) {
208+
this.contextPropagators = contextPropagators;
209+
return this;
210+
}
211+
200212
public WorkflowOptions build() {
201213
return new WorkflowOptions(
202214
workflowId,
@@ -207,7 +219,8 @@ public WorkflowOptions build() {
207219
retryOptions,
208220
cronSchedule,
209221
memo,
210-
searchAttributes);
222+
searchAttributes,
223+
contextPropagators);
211224
}
212225

213226
/**
@@ -253,7 +266,8 @@ public WorkflowOptions validateBuildWithDefaults() {
253266
retryOptions,
254267
cronSchedule,
255268
memo,
256-
searchAttributes);
269+
searchAttributes,
270+
contextPropagators);
257271
}
258272
}
259273

@@ -275,6 +289,8 @@ public WorkflowOptions validateBuildWithDefaults() {
275289

276290
private Map<String, Object> searchAttributes;
277291

292+
private List<ContextPropagator> contextPropagators;
293+
278294
private WorkflowOptions(
279295
String workflowId,
280296
WorkflowIdReusePolicy workflowIdReusePolicy,
@@ -284,7 +300,8 @@ private WorkflowOptions(
284300
RetryOptions retryOptions,
285301
String cronSchedule,
286302
Map<String, Object> memo,
287-
Map<String, Object> searchAttributes) {
303+
Map<String, Object> searchAttributes,
304+
List<ContextPropagator> contextPropagators) {
288305
this.workflowId = workflowId;
289306
this.workflowIdReusePolicy = workflowIdReusePolicy;
290307
this.executionStartToCloseTimeout = executionStartToCloseTimeout;
@@ -294,6 +311,7 @@ private WorkflowOptions(
294311
this.cronSchedule = cronSchedule;
295312
this.memo = memo;
296313
this.searchAttributes = searchAttributes;
314+
this.contextPropagators = contextPropagators;
297315
}
298316

299317
public String getWorkflowId() {
@@ -332,6 +350,10 @@ public Map<String, Object> getSearchAttributes() {
332350
return searchAttributes;
333351
}
334352

353+
public List<ContextPropagator> getContextPropagators() {
354+
return contextPropagators;
355+
}
356+
335357
@Override
336358
public boolean equals(Object o) {
337359
if (this == o) return true;
@@ -345,7 +367,8 @@ public boolean equals(Object o) {
345367
&& Objects.equals(retryOptions, that.retryOptions)
346368
&& Objects.equals(cronSchedule, that.cronSchedule)
347369
&& Objects.equals(memo, that.memo)
348-
&& Objects.equals(searchAttributes, that.searchAttributes);
370+
&& Objects.equals(searchAttributes, that.searchAttributes)
371+
&& Objects.equals(contextPropagators, that.contextPropagators);
349372
}
350373

351374
@Override
@@ -359,7 +382,8 @@ public int hashCode() {
359382
retryOptions,
360383
cronSchedule,
361384
memo,
362-
searchAttributes);
385+
searchAttributes,
386+
contextPropagators);
363387
}
364388

365389
@Override
@@ -387,6 +411,8 @@ public String toString() {
387411
+ '\''
388412
+ ", searchAttributes='"
389413
+ searchAttributes
414+
+ ", contextPropagators='"
415+
+ contextPropagators
390416
+ '\''
391417
+ '}';
392418
}

0 commit comments

Comments
 (0)