Created
April 29, 2016 22:49
-
-
Save timcharper/74e1182badd8458d723bca4c8641280f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package m | |
import akka.stream.scaladsl._ | |
import akka.stream._ | |
import akka.actor._ | |
object Main extends App { | |
implicit val system = ActorSystem("hi") | |
implicit val materializer = ActorMaterializer() | |
implicit val ec = system.dispatcher | |
val (input, completed) = Source.actorRef[Int](0, OverflowStrategy.dropNew). | |
conflate { (prior, overflown) => | |
println(s"dropping overflown ${overflown}") | |
prior | |
}. | |
buffer(10, OverflowStrategy.backpressure). | |
async. | |
toMat(Sink.foreach { n => | |
println(n) | |
Thread.sleep(100) | |
})(Keep.both). | |
run | |
(1 to 50).foreach { n => | |
input ! n | |
println(s"sent ${n}") | |
Thread.sleep(10) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment