@@ -91,10 +91,9 @@ sealed interface Context {
9191 ): InvocationHandle <Res >
9292
9393 /* *
94- * Execute a non-deterministic closure, recording the result value in the journal. The result
95- * value will be re-played in case of re-invocation (e.g. because of failure recovery or
96- * suspension point) without re-executing the closure. Use this feature if you want to perform
97- * <b>non-deterministic operations</b>.
94+ * Execute a closure, recording the result value in the journal. The result value will be
95+ * re-played in case of re-invocation (e.g. because of failure recovery or suspension point)
96+ * without re-executing the closure.
9897 *
9998 * You can name this closure using the `name` parameter. This name will be available in the
10099 * observability tools.
@@ -146,6 +145,22 @@ sealed interface Context {
146145 return runAsync(typeTag, name, retryPolicy, block).await()
147146 }
148147
148+ /* *
149+ * Execute a closure asynchronously. This is like [runBlock], but it returns a [DurableFuture]
150+ * that you can combine and select.
151+ *
152+ * ```
153+ * // Fan out the subtasks - run them in parallel
154+ * val futures = subTasks.map { subTask ->
155+ * ctx.runAsync { subTask.execute() }
156+ * }
157+ *
158+ * // Fan in - Await all results and aggregate
159+ * val results = futures.awaitAll()
160+ * ```
161+ *
162+ * @see runBlock
163+ */
149164 suspend fun <T : Any ?> runAsync (
150165 typeTag : TypeTag <T >,
151166 name : String = "",
@@ -203,10 +218,12 @@ inline fun <reified Res : Any?> Context.invocationHandle(
203218}
204219
205220/* *
206- * Execute a non-deterministic closure, recording the result value in the journal. The result value
207- * will be re-played in case of re-invocation (e.g. because of failure recovery or suspension point)
208- * without re-executing the closure. Use this feature if you want to perform <b>non-deterministic
209- * operations</b>.
221+ * Execute a closure, recording the result value in the journal. The result value will be re-played
222+ * in case of re-invocation (e.g. because of failure recovery or suspension point) without
223+ * re-executing the closure.
224+ *
225+ * You can name this closure using the `name` parameter. This name will be available in the
226+ * observability tools.
210227 *
211228 * <p>The closure should tolerate retries, that is Restate might re-execute the closure multiple
212229 * times until it records a result. To control and limit the amount of retries, pass a [RetryPolicy]
@@ -240,6 +257,7 @@ inline fun <reified Res : Any?> Context.invocationHandle(
240257 *
241258 * To propagate failures to the run call-site, make sure to wrap them in [TerminalException].
242259 *
260+ * @param name the name of the side effect.
243261 * @param block closure to execute.
244262 * @param T type of the return value.
245263 * @return value of the runBlock operation.
@@ -252,6 +270,22 @@ suspend inline fun <reified T : Any> Context.runBlock(
252270 return this .runBlock(typeTag<T >(), name, retryPolicy, block)
253271}
254272
273+ /* *
274+ * Execute a closure asynchronously. This is like [runBlock], but it returns a [DurableFuture] that
275+ * you can combine and select.
276+ *
277+ * ```
278+ * // Fan out the subtasks - run them in parallel
279+ * val futures = subTasks.map { subTask ->
280+ * ctx.runAsync { subTask.execute() }
281+ * }
282+ *
283+ * // Fan in - Await all results and aggregate
284+ * val results = futures.awaitAll()
285+ * ```
286+ *
287+ * @see runBlock
288+ */
255289suspend inline fun <reified T : Any > Context.runAsync (
256290 name : String = "",
257291 retryPolicy : RetryPolicy ? = null,
0 commit comments