"Source" and "OverflowStrategy" are parts of Akka streams. How can I reimplement below code in FS2?
object Topic {
def apply: Topic = {
val (a1, a2) = Source.queue[Message[_]](100, OverflowStrategy.backpressure).preMaterialize()
val (b1, b2) = Source.queue[Signal](100, OverflowStrategy.backpressure).preMaterialize()
new Topic(a1, a2, b1, b2)
}
}
In fs2 there are several constructors, for example
Queue.bounded[F, M](maxSize)orQueue.circularBuffer[F, M](maxSize). For backpressure you should useQueue.bounded[F, M](maxSize). It will do the same as the backpressure strategy for akka queue.The full list of methods: https://www.javadoc.io/doc/co.fs2/fs2-core_2.13/2.2.2/fs2/concurrent/Queue$.html
You will have something like this:
Also, you can consider using prebuild Topic type from FS2. https://www.javadoc.io/doc/co.fs2/fs2-core_2.13/2.2.2/fs2/concurrent/Topic.html