Carmine library explanation for Redis pub/sub

Hey all, I’m trying to write a graphql API along with redis pub/sub functionality with lacinia and carmine.
According to the docs I understood how the basic listener and channel initialization works.

(def listener
  (car/with-new-pubsub-listener (:spec server1-conn)
    {"foobar" (fn f1 [msg] (println "Channel match: " msg))}
   (car/subscribe  "foobar")))

This is how the channel is made and we can publish data into this channel via

(wcar* (car/publish "foobar" "Hello to foobar!"))

But how can we retrieve the data out of this channel? and what’s this part?

(with-open-listener listener
  (car/unsubscribe) ; Unsubscribe from every channel (leave patterns alone)
  (car/psubscribe "an-extra-channel"))

(swap! (:state listener) assoc "*extra*" (fn [x] (println "EXTRA: " x)))

We gave up trying to use Carmine and wrote our own Redis pub/sub code (and our own Redis connection pooling code too), based on Jedis.

Can you tell me what this part is doing?

(with-open-listener listener
  (car/unsubscribe) ; Unsubscribe from every channel (leave patterns alone)
  (car/psubscribe "an-extra-channel"))

(swap! (:state listener) assoc "*extra*" (fn [x] (println "EXTRA: " x)))

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.