Skip to content

Instantly share code, notes, and snippets.

@DavidRdgz
Created February 22, 2016 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidRdgz/852a1583db5acfce3e63 to your computer and use it in GitHub Desktop.
Save DavidRdgz/852a1583db5acfce3e63 to your computer and use it in GitHub Desktop.
Running the Akka Streams examples
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