Created
January 6, 2020 15:44
-
-
Save colinbes/6523160d64c8340f0edc85accaa5055a to your computer and use it in GitHub Desktop.
Akka Source.queue for SSE
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
lazy val (sourceQueue, eventsSource) = Source.queue[String](Int.MaxValue, OverflowStrategy.backpressure) | |
.delay(1.seconds, DelayOverflowStrategy.backpressure) | |
.map(message => ServerSentEvent(message, Some("myEvent"))) | |
.keepAlive(1.second, () => ServerSentEvent.heartbeat) | |
.toMat(BroadcastHub.sink[ServerSentEvent])(Keep.both) | |
.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment