Add setup operator #26192

This commit is contained in:
Martynas Mickevičius 2019-05-17 09:54:18 +03:00 committed by Johan Andrén
parent 7b20b89ce0
commit 18d970fc8e
14 changed files with 574 additions and 4 deletions

View file

@ -295,6 +295,14 @@ object Source {
new Source(LinearTraversalBuilder.fromBuilder(other.traversalBuilder, other.shape, Keep.right), other.shape)
}
/**
* Defers the creation of a [[Source]] until materialization. The `factory` function
* exposes [[ActorMaterializer]] which is going to be used during materialization and
* [[Attributes]] of the [[Source]] returned by this method.
*/
def setup[T, M](factory: (ActorMaterializer, Attributes) Source[T, M]): Source[T, Future[M]] =
Source.fromGraph(new SetupSourceStage(factory))
/**
* Helper to create [[Source]] from `Iterable`.
* Example usage: `Source(Seq(1,2,3))`