You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2025/07/07 00:12:43 UTC

Re: [PR] feat: Add preMaterializeIntoSource [pekko]

pjfanning commented on code in PR #1831:
URL: https://github.com/apache/pekko/pull/1831#discussion_r2188751233


##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Source.scala:
##########
@@ -108,6 +108,21 @@ final class Source[+Out, +Mat](
     (mat, Source.fromPublisher(pub))
   }
 
+  /**
+   * Materializes this [[Source]] using the [[Sink]], immediately returning the values via the
+   * provided [[Sink]] as a new [[Source]].
+   *
+   * @param sink A sink which needs to materialize into a [[Future]], typically one
+   *             that collects values such as [[Sink.head]] or [[Sink.seq]]
+   * @return A new [[Source]] that contains the results of the provided [[Source]]'s
+   *         elements run with the [[Sink]]
+   * @since 1.2.0
+   */
+  def preMaterializeIntoSource[Mat2](sink: Graph[SinkShape[Out], Future[Mat2]]): Source[Mat2, Future[NotUsed]] =
+    Source.fromMaterializer { (mat, attr) =>
+      Source.future(this.withAttributes(attr).toMat(sink)(Keep.right).run()(mat))

Review Comment:
   @mdedetrich I'm hoping to do a 1.2.0-M2 release in the next week or 2. Is PR in a position to be completed in that time frame?



-- 
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: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org