SHARE
TWEET

Akka stream example

NLinker Feb 21st, 2018 30 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.vertigo.mapping.persistence
  2.  
  3. import akka.actor.ActorSystem
  4. import akka.stream._
  5. import akka.stream.scaladsl._
  6.  
  7. object X {
  8.   implicit val system: ActorSystem = ActorSystem("MyTest")
  9.   implicit val matt: ActorMaterializer = ActorMaterializer()
  10.  
  11.   def mainFlow(): Unit = {
  12.     val grp = RunnableGraph.fromGraph(GraphDSL.create() {
  13.       implicit builder =>
  14.         import GraphDSL.Implicits._
  15.         val src = builder.add(Source(1 to 100)).out
  16.         val flw1 = builder.add(Flow[Int].map(x => x * 10).take(20))
  17.         val flw2 = builder.add(Flow[Int].filter(x => x > 50))
  18.         val snk2 = builder.add(Sink.foreach(println)).in
  19.         src ~> flw1 ~> flw2 ~> snk2
  20.         ClosedShape
  21.     }).run
  22.   }
  23.  
  24.   def main(str: Array[String]): Unit = {
  25.     mainFlow()
  26.   }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top