If I’m breaking any rules by posting this, I’ll take it down. Sorry, I’m just very curious to know the answer for this.
I asked a question like this recently on StackOverflow but wanted to know if I can get some direction from the akka experts. Here is the question which has the total context:
TL;DR - The akka http websocket API wants a Flow which it can handle. I’m trying to use something like the below to give it a flow:
private lazy val connHub: Flow[Message, Message, UniqueKillSwitch] = {
val (sink, source) = MergeHub.source[Message].toMat(BroadcastHub.sink[Message])(Keep.both).run()
Flow.fromSinkAndSourceCoupled(sink, source).joinMat(KillSwitches.singleBidi[Message, Message])(Keep.right)
}
This will give me a Flow that materializes a KillSwitch. However, I’ve realized that I can’t materialize the kill switch myself since the websocket directive provided by Akka would do that. Because this is the case, how can I get the Kill Switch?
The only idea I have is maybe somehow feeding the Flow into a sink that I can somehow call prematerialize() on which I could somehow manipulate to give me the KillSwitch but I’m not sure if that is the correct way to do this?
Can someone with more experience and knowledge help in explaining the correct way to acheive what I want?
2 posts - 1 participant