This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-13
Channels
- # announcements (1)
- # babashka (30)
- # beginners (43)
- # biff (24)
- # calva (72)
- # cider (12)
- # clj-commons (24)
- # clj-on-windows (10)
- # cljsrn (23)
- # clojure (123)
- # clojure-bay-area (6)
- # clojure-europe (43)
- # clojure-losangeles (2)
- # clojure-nl (2)
- # clojure-uk (9)
- # clojurescript (125)
- # core-async (9)
- # cursive (2)
- # data-science (3)
- # datomic (30)
- # devops (1)
- # emacs (13)
- # events (5)
- # fulcro (15)
- # graalvm (3)
- # gratitude (1)
- # humbleui (11)
- # lsp (5)
- # nbb (24)
- # off-topic (11)
- # pedestal (5)
- # releases (1)
- # remote-jobs (1)
- # sci (15)
- # scittle (16)
- # shadow-cljs (15)
- # sql (11)
- # tools-deps (9)
- # xtdb (5)
Is an ordinary chan that receives 1 value and is then closed better than promise-chan? It looks like the former better represents semantics of receiving a value and then stopping than the latter. Not sure when to use what…
You use a promise chan if you want the value to stay there forever. A regular channel, once you read from it, will not contain that value anymore. Take once or take many times?
For example, using read-once chans, if you have multiple services to ask the same question, you can send requests to every one of them and a/merge
response chans, and now we have a chan that contains all responses and then closes. That’s useful. What about promise-chan? Where I can use that?
Can someone explain how to arrange a chan closing? Existing chan combinatorics seem to close downstream when upstream closes, but when the downstream closes, they only stop consuming from upstream without closing it. What are the consequences of this behavior? Should I strive for the same behavior when writing my own go loops that do similar consumption from upstream/feeding the downstream processing? What if I close upstream when downstream closes?
You can test puts on the downstream channel. They return false if it's closed. Then you can decide what to do, either propagate closing upwards or leave it hanging
My understanding is: if someone else might consume from upstream, we should leave it hanging so processing can continue. If no one else can consume from upstream, we should close because otherwise we will be just filling up the buffer for a while without any resolution possible. Correct?