2014-12-08 17:29:40 +01:00
|
|
|
package docs.stream.cookbook
|
|
|
|
|
|
2016-01-20 10:00:37 +02:00
|
|
|
import akka.NotUsed
|
2015-10-21 22:45:39 +02:00
|
|
|
import akka.stream.ClosedShape
|
2014-12-08 17:29:40 +01:00
|
|
|
import akka.stream.scaladsl._
|
2015-04-24 11:45:03 +03:00
|
|
|
import akka.stream.testkit._
|
2014-12-08 17:29:40 +01:00
|
|
|
import akka.util.ByteString
|
|
|
|
|
|
|
|
|
|
class RecipeKeepAlive extends RecipeSpec {
|
|
|
|
|
|
|
|
|
|
"Recipe for injecting keepalive messages" must {
|
|
|
|
|
|
|
|
|
|
"work" in {
|
|
|
|
|
val keepaliveMessage = ByteString(11)
|
|
|
|
|
|
|
|
|
|
//#inject-keepalive
|
2015-11-02 15:30:10 +01:00
|
|
|
import scala.concurrent.duration._
|
2016-01-20 10:00:37 +02:00
|
|
|
val injectKeepAlive: Flow[ByteString, ByteString, NotUsed] =
|
2015-11-02 15:30:10 +01:00
|
|
|
Flow[ByteString].keepAlive(1.second, () => keepaliveMessage)
|
2014-12-08 17:29:40 +01:00
|
|
|
//#inject-keepalive
|
|
|
|
|
|
2015-11-02 15:30:10 +01:00
|
|
|
// No need to test, this is a built-in stage with proper tests
|
2014-12-08 17:29:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|