Fork me on GitHub
#clojure
<
2020-08-11
>
subsaharancoder01:08:01

I'm building an API using pedestal, I need to extract body params, but can't seem to create a proper route:

["/api/users"
       :post [(body-params/body-params)]
       user-handler
       :route-name :user-handler
       ]
keeps throwing this error:
Assert failed: In row 5, there were unused elements (#object[ping_holiday.routes$user_handler 0x4d81a56a "ping_holiday.routes$user_handler@4d81a56a"] :route-name :user-handler).
The whole route was: ["/api/users" :post [#Interceptor{:name :io.pedestal.http.body-params/body-params}] #object[ping_holiday.routes$user_handler 0x4d81a56a "ping_holiday.routes$user_handler@4d81a56a"] :route-name :user-handler]
(empty? (:remaining ctx))
any idea how to fix this?

seancorfield01:08:31

@johnwesonga Maybe ask in #pedestal ? I'm not sure how widely used it is...

vemv02:08:00

Yes #pedestal tends to be responsive :)

seb23109:08:02

Morning all. Can anyone give me any advice on accessing the content of resources in a library? I have aped other examples I have seen doing similar things, and when running a REPL in this project it works, however when I try to call this library from elsewhere it doesn’t recognise that there’s a file in the resources dir called bar.csv

(def foo
  (with-open [file (io/input-stream (io/resource "bar.csv"))]
    (u/load-csv file)))

seb23109:08:20

It just returns a nil when trying to compile

seb23109:08:29

Cannot open <nil> as an InputStream.

deas10:08:40

I need to make some basic edits to namespaced XML (SOAP). What should I be reaching out for? clojure.zip+ clojure.data.xml?

borkdude11:08:12

Is there a way to unload implementations for a certain protocol?

(keys (:impls clojure.core.protocols/Datafiable))
Maybe hacking the Datafiable var?

Ben Hammond13:08:45

apologies if this is the wrong forum, but I am investigating larger-than-expected JIT CodeCache sizes in my JVM; I am wondering if I can partly blame this on anonymous classes; if I have 10 million instances of an anonymous class that are all functionally the same will they get compiled into 10 million distinct CodeCache nmethods? Would convering into a named class make a noticeable difference, do you think?

jumar17:08:59

What is larger than expected and under what conditions it happens?

ghadi13:08:56

if it's the same class then no

ghadi13:08:17

if you're evaling the same form over and over again, it may generate new classes

ghadi13:08:57

can share a sample @ben.hammond? are you doing eval regularly in this JVM?

borkdude14:08:41

I recall vaguely that there was a discussion about making tools.analyzer for core.async optional (if you don't use go routines anyway). Was there?

ghadi14:08:52

sort of but not quite. the discussion was about avoiding loading tools.analyzer if the core.async code was AOTed

ghadi14:08:07

tools.analyzer is only needed at macroexpansion time

ghadi14:08:41

core.async itself uses go blocks

borkdude14:08:56

ah ok. I was pondering about this because core.async loads clojure.reflect (indirectly via tools.analyzer) which kinda bloats my GraalVM binary with 30mb, but there are maybe other ways of getting out of that

borkdude14:08:08

(in combination with clojure.datafy this is, not only with core.async)

borkdude14:08:43

what I really want is to opt of out of some datafy implementations to keep my binary lean

borkdude14:08:59

but I guess that isn't really possible

borkdude14:08:05

without patching a bunch of namespaces

ghadi14:08:47

you might be in "fork" territory

borkdude14:08:15

wouldn't be the first time. it's always a solution, but maybe there are nicer ways

borkdude15:08:34

FWIW overriding the protocol implementation for a type with something else works to keep the binary lean! Just gotta be very careful about the order (speaks for itself).

borkdude15:08:16

clojure.core/*loading-verbosely* is a super helpful tool to track this

borkdude15:08:37

Turns out that clojure.reflect isn't the problem, it's the Datafiable for clojure.lang.Namespace that gets a bloated binary.

wombawomba15:08:29

Is there any Clojure library I can use to syntax highlight a JSON string without parsing it to a Clojure object? Or is there something I can use to build such a library myself?