pekko/akka-docs-dev/rst/scala/code/docs/stream/cookbook/RecipeKeepAlive.scala
Endre Sándor Varga 8e62c0d9d7 +str 18735: Added keepalive inject and initial delay ops
Also, improved documentation of timeout operations
Added missing Java DSL smoke tests
2015-11-03 10:49:43 +01:00

25 lines
615 B
Scala

package docs.stream.cookbook
import akka.stream.ClosedShape
import akka.stream.scaladsl._
import akka.stream.testkit._
import akka.util.ByteString
class RecipeKeepAlive extends RecipeSpec {
"Recipe for injecting keepalive messages" must {
"work" in {
val keepaliveMessage = ByteString(11)
//#inject-keepalive
import scala.concurrent.duration._
val injectKeepAlive: Flow[ByteString, ByteString, Unit] =
Flow[ByteString].keepAlive(1.second, () => keepaliveMessage)
//#inject-keepalive
// No need to test, this is a built-in stage with proper tests
}
}
}