Hello,
I have a grpc service where the server is streaming the result of some calculation to clients. The requirement is that all clients will get the same result. The calculation runs periodically.
What I have just now is the following:
val graph =
Source
.tick(delay,interval, SomeTick())
.map(x=> calc(x))
.preMaterialize()._2
.toMat(BroadcastHub.sink(bufferSize = 256))(Keep.right)
val drainer = graph.run.runWith(Sink.ignore)
override def service(): Source[Something, NotUsed] = {
graph.run
}
I’m not sure if this is correct or not, as it seems to hang some of the time. Can anyone recommend the best approach for this?
Thanks!