This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-27
Channels
- # announcements (2)
- # aws (31)
- # babashka (81)
- # beginners (82)
- # calva (38)
- # clj-kondo (41)
- # cljdoc (4)
- # cljs-dev (6)
- # clojure (101)
- # clojure-belgium (1)
- # clojure-europe (30)
- # clojure-germany (1)
- # clojure-italy (7)
- # clojure-nl (4)
- # clojure-norway (1)
- # clojure-spec (1)
- # clojure-uk (19)
- # clojurescript (16)
- # clojutre (1)
- # community-development (26)
- # core-logic (2)
- # data-science (26)
- # datomic (71)
- # events (3)
- # fulcro (55)
- # graalvm (2)
- # graphql (3)
- # joker (2)
- # kaocha (19)
- # luminus (2)
- # malli (6)
- # meander (3)
- # off-topic (6)
- # pathom (34)
- # random (1)
- # re-frame (2)
- # robots (1)
- # shadow-cljs (37)
- # sql (30)
- # tools-deps (21)
- # xtdb (4)
- # yada (25)
Why does aws-api use put!
instead of >!
https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L90?
That wasn't all inside a go block before.
Does response-ch https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L82 get garbage collected if region, creds, or endpoint result an anomaly? It seems like a bunch of channels could end up getting built up due to https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L107-L115 running even when region/creds/endpoint fetch result in an anomaly.
in this case you can think of response-ch as being a promise, which will be gc'ed when there are no references to it
Isn't https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L109 going to hold a reference to it forever if any branch besides the :else
is hit?
a go block is transformed in to a callback that is registered on a channel, so if there are no other references to a channel, a channel will get gc'ed even if a go block is waiting to put or take from it
Ah, makes sense! Thanks for that explanation. So in this case, the gc will know immediately there will be no references to response-ch since the :else branch was not run, marking the channel for gc?
whenever the gc happens to run, if it decides to collect more garbage, it might eventually notice the channel is garbage
Passing a transducer to the response-ch chan
https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L82 that does the mapping written in the https://github.com/cognitect-labs/aws-api/blob/954bd3c0376d84a7defe5215b9f2dee3059e421f/src/cognitect/aws/client.clj#L107.
Cleaner is subjective. For me the separation of "here's all the stuff we do to make a request" from "here's what we do with a response" is easier to reason about.
"more efficient" is less so, of course 🙂
Are you just thinking of the extra go block, or something else?
Got it.
I appreciate the input, @kenny. Thanks.