Last active
November 29, 2015 12:10
-
-
Save binshuohu/9873c10365363aff4e7b to your computer and use it in GitHub Desktop.
Status.Success doesn't complete the stream
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 sample.stream | |
import akka.actor.ActorSystem | |
import akka.stream.{ OverflowStrategy, ActorMaterializer } | |
import akka.stream.scaladsl._ | |
import akka.actor.Status | |
import scala.util.{ Failure, Success } | |
object BasicTransformation { | |
def main(args: Array[String]): Unit = { | |
implicit val system = ActorSystem("Sys") | |
import system.dispatcher | |
implicit val materializer = ActorMaterializer() | |
val (actor, future) = Source.actorRef[Int](1024, OverflowStrategy.fail) | |
.toMat(Sink.fold[Int, Int](0)(_ + _))(Keep.both) | |
.run() | |
future onComplete { | |
case Success(res) => | |
println(s"result is $res") | |
system.terminate() | |
case Failure(e) => | |
println(s"Failure: $e") | |
system.terminate() | |
} | |
actor ! 1 | |
actor ! 2 | |
actor ! Status.Success //it doesn't complete the stream and is treated like a normal element, something wrong? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment