Created
March 11, 2018 22:25
-
-
Save amoilanen/baebef9dabea345e37d04b55a8f8d532 to your computer and use it in GitHub Desktop.
Simple example of a stream in Akka: source -> flow -> sink
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
import akka.actor.ActorSystem | |
import akka.stream.scaladsl._ | |
import akka.stream._ | |
object AkkaStreamExample extends App { | |
implicit val system = ActorSystem("MyActorSystem") | |
implicit val materializer = ActorMaterializer() | |
val source = Source(1 to 5) | |
val square = Flow[Int].map(x => x * x) | |
val sink = Sink.foreach[Int](println) | |
(source via square to sink).run | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment