24
24
import com .uber .cadence .internal .sync .WorkflowInternal ;
25
25
import com .uber .cadence .worker .WorkerOptions ;
26
26
import com .uber .cadence .workflow .Functions .Func ;
27
- import com .uber .cadence .workflow .Functions .Func1 ;
28
- import com .uber .cadence .workflow .Functions .Func2 ;
29
- import com .uber .cadence .workflow .Functions .Proc ;
30
27
import com .uber .m3 .tally .Scope ;
31
28
import java .lang .reflect .Type ;
32
29
import java .time .Duration ;
156
153
* methods allow you to invoke any activity asynchronously. The call returns a {@link Promise}
157
154
* result immediately. {@link Promise} is similar to both {@link java.util.concurrent.Future} and
158
155
* {@link java.util.concurrent.CompletionStage}. The {@link Promise#get()} blocks until a result is
159
- * available. It also exposes the {@link Promise#thenApply(Func1)} and {@link Promise#handle(Func2)}
160
- * methods. See the {@link Promise} documentation for technical details about differences with
161
- * {@link java.util.concurrent.Future}.
156
+ * available. It also exposes the {@link Promise#thenApply(Functions. Func1)} and {@link
157
+ * Promise#handle(Functions.Func2)} methods. See the {@link Promise} documentation for technical
158
+ * details about differences with {@link java.util.concurrent.Future}.
162
159
*
163
160
* <p>To convert a synchronous call
164
161
*
165
162
* <pre><code>
166
163
* String localName = activities.download(sourceBucket, sourceFile);
167
164
* </code></pre>
168
165
*
169
- * to asynchronous style, the method reference is passed to {@link Async#function(Func)} or {@link
170
- * Async#procedure(Proc)} followed by activity arguments:
166
+ * to asynchronous style, the method reference is passed to {@link Async#function(Functions. Func)}
167
+ * or {@link Async#procedure(Functions. Proc)} followed by activity arguments:
171
168
*
172
169
* <pre><code>
173
170
* Promise<String> localNamePromise = Async.function(activities::download, sourceBucket, sourceFile);
243
240
*
244
241
* <p>The first call to the child workflow stub must always be to a method annotated with
245
242
* {@literal @}{@link WorkflowMethod}. Similarly to activities, a call can be synchronous or
246
- * asynchronous using {@link Async#function(Func)} or {@link Async#procedure(Proc)}. The synchronous
247
- * call blocks until a child workflow completes. The asynchronous call returns a {@link Promise}
248
- * that can be used to wait for the completion. After an async call returns the stub, it can be used
249
- * to send signals to the child by calling methods annotated with {@literal @}{@link SignalMethod}.
250
- * Querying a child workflow by calling methods annotated with {@literal @}{@link QueryMethod} from
251
- * within workflow code is not supported. However, queries can be done from activities using the
252
- * {@link com.uber.cadence.client.WorkflowClient} provided stub.
243
+ * asynchronous using {@link Async#function(Functions.Func)} or {@link
244
+ * Async#procedure(Functions.Proc)}. The synchronous call blocks until a child workflow completes.
245
+ * The asynchronous call returns a {@link Promise} that can be used to wait for the completion.
246
+ * After an async call returns the stub, it can be used to send signals to the child by calling
247
+ * methods annotated with {@literal @}{@link SignalMethod}. Querying a child workflow by calling
248
+ * methods annotated with {@literal @}{@link QueryMethod} from within workflow code is not
249
+ * supported. However, queries can be done from activities using the {@link
250
+ * com.uber.cadence.client.WorkflowClient} provided stub.
253
251
*
254
252
* <pre><code>
255
253
* public interface GreetingChild {
338
336
* for this.
339
337
* <li>Only use {@link #currentTimeMillis()} to get the current time inside a workflow.
340
338
* <li>Do not use native Java {@link Thread} or any other multi-threaded classes like {@link
341
- * java.util.concurrent.ThreadPoolExecutor}. Use {@link Async#function(Func)} or {@link
342
- * Async#procedure(Proc)} to execute code asynchronously.
339
+ * java.util.concurrent.ThreadPoolExecutor}. Use {@link Async#function(Functions. Func)} or
340
+ * {@link Async#procedure(Functions. Proc)} to execute code asynchronously.
343
341
* <li>Don't use any synchronization, locks, and other standard Java blocking concurrency-related
344
342
* classes besides those provided by the Workflow class. There is no need in explicit
345
343
* synchronization because multi-threaded code inside a workflow is executed one thread at a
@@ -904,7 +902,7 @@ public static boolean isReplaying() {
904
902
* @param resultClass type of the side effect
905
903
* @param func function that returns side effect value
906
904
* @return value of the side effect
907
- * @see #mutableSideEffect(String, Class, BiPredicate, Func)
905
+ * @see #mutableSideEffect(String, Class, BiPredicate, Functions. Func)
908
906
*/
909
907
public static <R > R sideEffect (Class <R > resultClass , Func <R > func ) {
910
908
return WorkflowInternal .sideEffect (resultClass , resultClass , func );
@@ -959,21 +957,22 @@ public static <R> R sideEffect(Class<R> resultClass, Func<R> func) {
959
957
* @param resultType type of the side effect. Differs from resultClass for generic types.
960
958
* @param func function that returns side effect value
961
959
* @return value of the side effect
962
- * @see #mutableSideEffect(String, Class, BiPredicate, Func)
960
+ * @see #mutableSideEffect(String, Class, BiPredicate, Functions. Func)
963
961
*/
964
962
public static <R > R sideEffect (Class <R > resultClass , Type resultType , Func <R > func ) {
965
963
return WorkflowInternal .sideEffect (resultClass , resultType , func );
966
964
}
967
965
968
966
/**
969
- * {@code mutableSideEffect} is similar to {@link #sideEffect(Class, Func)} in allowing calls of
970
- * non-deterministic functions from workflow code.
967
+ * {@code mutableSideEffect} is similar to {@link #sideEffect(Class, Functions. Func)} in allowing
968
+ * calls of non-deterministic functions from workflow code.
971
969
*
972
- * <p>The difference between {@code mutableSideEffect} and {@link #sideEffect(Class, Func)} is
973
- * that every new {@code sideEffect} call in non-replay mode results in a new marker event
974
- * recorded into the history. However, {@code mutableSideEffect} only records a new marker if a
975
- * value has changed. During the replay, {@code mutableSideEffect} will not execute the function
976
- * again, but it will return the exact same value as it was returning during the non-replay run.
970
+ * <p>The difference between {@code mutableSideEffect} and {@link #sideEffect(Class,
971
+ * Functions.Func)} is that every new {@code sideEffect} call in non-replay mode results in a new
972
+ * marker event recorded into the history. However, {@code mutableSideEffect} only records a new
973
+ * marker if a value has changed. During the replay, {@code mutableSideEffect} will not execute
974
+ * the function again, but it will return the exact same value as it was returning during the
975
+ * non-replay run.
977
976
*
978
977
* <p>One good use case of {@code mutableSideEffect} is to access a dynamically changing config
979
978
* without breaking determinism. Even if called very frequently the config value is recorded only
@@ -991,22 +990,23 @@ public static <R> R sideEffect(Class<R> resultClass, Type resultType, Func<R> fu
991
990
* for the first value.
992
991
* @param resultClass class of the side effect
993
992
* @param func function that produces a value. This function can contain non deterministic code.
994
- * @see #sideEffect(Class, Func)
993
+ * @see #sideEffect(Class, Functions. Func)
995
994
*/
996
995
public static <R > R mutableSideEffect (
997
996
String id , Class <R > resultClass , BiPredicate <R , R > updated , Func <R > func ) {
998
997
return WorkflowInternal .mutableSideEffect (id , resultClass , resultClass , updated , func );
999
998
}
1000
999
1001
1000
/**
1002
- * {@code mutableSideEffect} is similar to {@link #sideEffect(Class, Func)} in allowing calls of
1003
- * non-deterministic functions from workflow code.
1001
+ * {@code mutableSideEffect} is similar to {@link #sideEffect(Class, Functions. Func)} in allowing
1002
+ * calls of non-deterministic functions from workflow code.
1004
1003
*
1005
- * <p>The difference between {@code mutableSideEffect} and {@link #sideEffect(Class, Func)} is
1006
- * that every new {@code sideEffect} call in non-replay mode results in a new marker event
1007
- * recorded into the history. However, {@code mutableSideEffect} only records a new marker if a
1008
- * value has changed. During the replay, {@code mutableSideEffect} will not execute the function
1009
- * again, but it will return the exact same value as it was returning during the non-replay run.
1004
+ * <p>The difference between {@code mutableSideEffect} and {@link #sideEffect(Class,
1005
+ * Functions.Func)} is that every new {@code sideEffect} call in non-replay mode results in a new
1006
+ * marker event recorded into the history. However, {@code mutableSideEffect} only records a new
1007
+ * marker if a value has changed. During the replay, {@code mutableSideEffect} will not execute
1008
+ * the function again, but it will return the exact same value as it was returning during the
1009
+ * non-replay run.
1010
1010
*
1011
1011
* <p>One good use case of {@code mutableSideEffect} is to access a dynamically changing config
1012
1012
* without breaking determinism. Even if called very frequently the config value is recorded only
@@ -1025,7 +1025,7 @@ public static <R> R mutableSideEffect(
1025
1025
* @param resultClass class of the side effect
1026
1026
* @param resultType type of the side effect. Differs from resultClass for generic types.
1027
1027
* @param func function that produces a value. This function can contain non deterministic code.
1028
- * @see #sideEffect(Class, Func)
1028
+ * @see #sideEffect(Class, Functions. Func)
1029
1029
*/
1030
1030
public static <R > R mutableSideEffect (
1031
1031
String id , Class <R > resultClass , Type resultType , BiPredicate <R , R > updated , Func <R > func ) {
@@ -1134,8 +1134,8 @@ public static Scope getMetricsScope() {
1134
1134
}
1135
1135
1136
1136
/**
1137
- * Get logger to use inside workflow. Logs in replay mode are omitted unless {@param
1138
- * enableLoggingInReplay} is set to true in {@link WorkerOptions} when a worker starts up.
1137
+ * Get logger to use inside workflow. Logs in replay mode are omitted unless enableLoggingInReplay
1138
+ * is set to true in {@link WorkerOptions} when a worker starts up.
1139
1139
*
1140
1140
* @param clazz class name to appear in logging.
1141
1141
* @return logger to use in workflow logic.
@@ -1145,8 +1145,8 @@ public static Logger getLogger(Class<?> clazz) {
1145
1145
}
1146
1146
1147
1147
/**
1148
- * Get logger to use inside workflow. Logs in replay mode are omitted unless {@param
1149
- * enableLoggingInReplay} is set to true in {@link WorkerOptions} when a worker starts up.
1148
+ * Get logger to use inside workflow. Logs in replay mode are omitted unless enableLoggingInReplay
1149
+ * is set to true in {@link WorkerOptions} when a worker starts up.
1150
1150
*
1151
1151
* @param name name to appear in logging.
1152
1152
* @return logger to use in workflow logic.
0 commit comments