He-Pin commented on code in PR #989:
URL: https://github.com/apache/incubator-pekko/pull/989#discussion_r1468516915
##########
docs/src/main/paradox/stream/operators/Sink/forall.md:
##########
@@ -0,0 +1,47 @@
+# Sink.forall
+
+A `Sink` that will test the given predicate `p` for every received element and
completes with the result.
+
+@ref[Sink operators](../index.md#sink-operators)
+
+## Signature
+
+@apidoc[Sink.forall](Sink$) {
scala="#forall%5BT%5D(p%3A%20T%20%3D%3E%20Boolean):org.apache.pekko.stream.scaladsl.Sink[T,scala.concurrent.Future[Boolean]]"
java="#forall(org.apache.pekko.japi.function.Predicate)" }
+
+## Description
+forall applies a predicate function to assert each element received, it
returns true if all elements satisfy the assertion, otherwise it returns false.
+
+It materializes into a `Future` (in Scala) or a `CompletionStage` (in Java)
that completes with the last state when the stream has finished.
+
+Notes that if source is empty, it will return true
+
+A `Sink` that will test the given predicate `p` for every received element and
+
+ - completes and returns @scala[`Future`] @java[`CompletionStage`] of `true`
if the predicate is true for all elements;
+ - completes and returns @scala[`Future`] @java[`CompletionStage`] of `true`
if the stream is empty (i.e. completes before signalling any elements);
+ - completes and returns @scala[`Future`] @java[`CompletionStage`] of `false`
if the predicate is false for any element.
+
+The materialized value @scala[`Future`] @java[`CompletionStage`] will be
completed with the value `true` or `false`
+when the input stream ends, or completed with `Failure` if there is a failure
signaled in the stream.
Review Comment:
It depends on the supervision behavior, with the restart strategy, if there
are two elements and one matches and one doesn't, and the later unmatched one
causes an Exception, then it should well return `true`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]