Split example to ease into the details. PR Comments

This commit is contained in:
Ignasi Marimon-Clos 2020-06-09 15:53:04 +02:00
parent 506cbc5bf4
commit 6eb1a9e1ef
3 changed files with 45 additions and 12 deletions

View file

@ -28,13 +28,22 @@ object Throttle extends App {
// val frameSource: Source[Frame,_]
val videoThrottling = frameSource.throttle(
framesPerSecond,
1.second,
framesPerSecond * 30, // maximumBurst
ThrottleMode.shaping)
1.second)
// serialize `Frame` and send over the network.
// #throttle
videoThrottling.to(Sink.foreach(println)).run()
// #throttle-with-burst
// val frameSource: Source[Frame,_]
val videoThrottlingWithBurst = frameSource.throttle(
framesPerSecond,
1.second,
framesPerSecond * 30, // maximumBurst
ThrottleMode.Shaping)
// serialize `Frame` and send over the network.
// #throttle-with-burst
videoThrottling.take(1000).to(Sink.foreach(println)).run()
videoThrottlingWithBurst.take(1000).to(Sink.foreach(println)).run()
}
object ThrottleCommon {