Headers and formats

This commit is contained in:
Ignasi Marimon-Clos 2020-07-07 14:58:56 +02:00
parent 0e3b4605ad
commit 024710a6e0
2 changed files with 61 additions and 63 deletions

View file

@ -1,3 +1,7 @@
/*
* Copyright (C) 2020 Lightbend Inc. <https://www.lightbend.com>
*/
package docs.stream.operators.sourceorflow
import akka.Done
@ -15,7 +19,7 @@ import scala.concurrent.Future
import scala.concurrent.duration._
/**
*
*
*/
class Monitor {
@ -38,14 +42,9 @@ class Monitor {
}
}
val monitoredSource: Source[Int, FlowMonitor[Int]] = source
.take(6)
.throttle(5, 1.second)
.monitorMat(Keep.right)
val monitoredSource: Source[Int, FlowMonitor[Int]] = source.take(6).throttle(5, 1.second).monitorMat(Keep.right)
val monitoredStream: (FlowMonitor[Int], Future[Done]) =
monitoredSource
.toMat(Sink.foreach(println))(Keep.both)
.run()
monitoredSource.toMat(Sink.foreach(println))(Keep.both).run()
val flowMonitor = monitoredStream._1