System wide materializer (#27491)
Introduces a materializer started through an extension and then an implicit conversion for Scala turning an implicitly available ActorSystem into a materializer. The Java APIs has been ammended with run-methods accepting an ActorSystem.
This commit is contained in:
parent
77d1d33dbc
commit
45c826a218
196 changed files with 1148 additions and 1129 deletions
|
|
@ -23,6 +23,7 @@ import org.scalatest.concurrent._
|
|||
|
||||
//#main-app
|
||||
object Main extends App {
|
||||
implicit val system = ActorSystem("QuickStart")
|
||||
// Code here
|
||||
}
|
||||
//#main-app
|
||||
|
|
@ -33,17 +34,14 @@ class QuickStartDocSpec extends WordSpec with BeforeAndAfterAll with ScalaFuture
|
|||
def println(any: Any) = () // silence printing stuff
|
||||
|
||||
"demonstrate Source" in {
|
||||
//#create-materializer
|
||||
implicit val system = ActorSystem("QuickStart")
|
||||
implicit val materializer = ActorMaterializer()
|
||||
//#create-materializer
|
||||
|
||||
//#create-source
|
||||
val source: Source[Int, NotUsed] = Source(1 to 100)
|
||||
//#create-source
|
||||
|
||||
//#run-source
|
||||
source.runForeach(i => println(i))(materializer)
|
||||
source.runForeach(i => println(i))
|
||||
//#run-source
|
||||
|
||||
//#transform-source
|
||||
|
|
@ -68,7 +66,7 @@ class QuickStartDocSpec extends WordSpec with BeforeAndAfterAll with ScalaFuture
|
|||
//#add-streams
|
||||
|
||||
//#run-source-and-terminate
|
||||
val done: Future[Done] = source.runForeach(i => println(i))(materializer)
|
||||
val done: Future[Done] = source.runForeach(i => println(i))
|
||||
|
||||
implicit val ec = system.dispatcher
|
||||
done.onComplete(_ => system.terminate())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue