Skip to content

Instantly share code, notes, and snippets.

@binshuohu
Last active November 29, 2015 12:10
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 binshuohu/9873c10365363aff4e7b to your computer and use it in GitHub Desktop.
Save binshuohu/9873c10365363aff4e7b to your computer and use it in GitHub Desktop.
Status.Success doesn't complete the stream
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