Fork me on GitHub
Marc Rios07:10:22

Hi, I'm trying to run a ring server, but every response I get back is an octet/stream object containing zero bytes. I'm pretty sure that I've just copied the examples from "Web Development With Clojure, 3rd edition".. I'm not sure where the problem could be coming from.

Marc Rios07:10:51

Any help or ideas would be appreciated.

Marc Rios07:10:12

Ok, I think the issue was that the reitit routes were missing a pair of brackets.


say you have required a namespace x.y.z :as some short name foobar. Now given foobar, how do you get back the qualified name x.y.z ?

Alex Miller (Clojure team)13:10:35

You can use ns-aliases to look it up

👍 1

I noticed two directory layout pattern: 1. - db.clj - db/{x,y,z}.clj 2. - db/{core, x, y, z.}.clj basically in the second one, the previous db.clj is changed to db/core.clj

Ben Sless15:10:40

With the caveat api is nicer than core, I vote 2


The second basically guarantees a dozen files called ‘core.clj’ in your project which seems suboptimal to me.

Ben Sless16:10:17

If it's a repository with many types of component.clj and component/{x,y,z}.clj then I agree with thom, 1 is preferable


I don't know that there is an "accepted" layout. Layout 2 (with core.clj) was more common in the past, mainly because that was/is the lein default. Nowadays, the defaults for newer tools (such as deps-new) are Layout 1.


I don't mind projects having a single ‘core’ namespace at the project level, although I wouldn't do it if it weren't the convention. But if you use core inside individual components of your app (e.g. what I assume is the database stuff here) I think that's unnecessarily generic.


If you have a dozen cores from version 2, @UTF99QP7V, that also means you have a dozen wodges of code that are almost little embedded libraries. So a dozen interfaces (cores) would be appropriate. Me, I find version 1 to be problematic in that it separates the main source from its subordinates, linked only casually by the directory being named the same as the source.clj


which one is more accpeted?


i like 2 better


I much prefer 1. Core is just a noise word that doesn't really tell you anything about the namespace and what code it contains. You might as well call it "misc" or "util".


apples need cores 😄


So do nuclear reactors. Neither of them are for general consumption ;-P

😂 1

Hello! I have a question regarding core.async and go blocks. I have an endpoint that makes several asynchronous HTTP calls. To do so I make each call using http-kit and put the result in a channel that is immediately closed. This is so I can merge all the channels together and proceed when all of the requests have finished. Now I used to do blocking waits on the channel, but I'd like to park instead to better use the machine's resources. I thought I would be able to serve the request in a go block and then use >! to park until the results are in, but it says it's not being called inside a go block. From what I understand core.async won't know its not inside a go block if its in an outer function. In that case, how would you suggest I change this code so that I'm not using a thread per request and not blocking until all of the HTTP requests have finished?

(defn call
  (let [channel (chan)]
    (http/get url
              (fn [{:keys [_ _ body _]}]     ;; asynchronous response handling
                (async/>!! channel body)
                (async/close! channel)))

(defn do-stuff
    (->> (map call urls)
         (async/into '())

(defroutes handler
           (POST "/do-stuff" [] (async/go (do-stuff *urls*))))


Hey #beginners, Java interop question: If a method is, and reflected at runtime, what does it mean that I still can't call it?


check our the requirements to call a varargs method here:


Beautiful, thank you.