Lamina undo siphon - Clojure

I use Lamina to implement the basic pubsub template.

When a client subscribes to a topic, I create a new channel for it (if it does not already exist), and then siphon it to the channel client. However, I cannot figure out how to cancel this so that the customer unsubscribes. I searched for documents and search queries but didn’t find anything.

How do I undo what siphon does?

+4
source share
2 answers

Typically, you will create a bridge channel that you can close, so the link:

topic-channel β†’ bridge-channel β†’ client-channel

In 0.5.0, this is easy because the siphon is variable:

 (defn cancellable-siphon [src dst] (let [bridge (channel)] (siphon src bridge dst) #(close bridge))) 
+1
source

You can fork upstream channel over the siphon and then ground the downstream channel, or if your graph allows you to simply close the channel, you no longer want the siphon to form the upstream channel.

ps: I will try to add an example later ...

+3
source

Source: https://habr.com/ru/post/1437683/


All Articles