Created
February 22, 2016 18:40
-
-
Save DavidRdgz/852a1583db5acfce3e63 to your computer and use it in GitHub Desktop.
Running the Akka Streams examples
This file contains 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 com.dvidr | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import akka.actor.ActorSystem | |
import akka.stream.ActorMaterializer | |
import akka.stream.scaladsl.{Sink, Source} | |
import scala.concurrent.Future | |
import scala.util.{Success, Failure} | |
class AkkaStreams | |
object AkkaStreams { | |
def main(args: Array[String]) { | |
implicit val actorSystem = ActorSystem("SimpleStreams") | |
implicit val materializer = ActorMaterializer() | |
val source = Source(1 to 10) | |
val sink = Sink.fold[Int, Int](0)(_ + _) | |
val sum: Future[Int] = source.runWith(sink) | |
sum.onComplete{ | |
case Success(n) => println(n) | |
case Failure(n) => println("Akka Actor failure.") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment