This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-20
Channels
- # aws-lambda (8)
- # beginners (37)
- # cider (43)
- # cljs-dev (12)
- # clojure (121)
- # clojure-italy (19)
- # clojure-nl (1)
- # clojure-poland (1)
- # clojure-russia (14)
- # clojure-spec (6)
- # clojure-uk (98)
- # clojurescript (28)
- # core-async (1)
- # cursive (7)
- # datomic (4)
- # emacs (63)
- # events (8)
- # fulcro (19)
- # graphql (4)
- # hoplon (3)
- # mount (1)
- # nrepl (101)
- # off-topic (15)
- # om (3)
- # pedestal (2)
- # portkey (31)
- # protorepl (2)
- # re-frame (26)
- # reagent (26)
- # reitit (2)
- # shadow-cljs (58)
- # spacemacs (8)
- # specter (5)
- # sql (56)
- # test-check (11)
- # tools-deps (48)
- # vim (52)
I see this https://github.com/vlacs/saml20-clj but I don’t see how to fit the pieces together
here is a design pattern I am running into. I have a
(try ... (catch ...) (finally ...))
block.
I am writing code inside the try section. I want to automatically add a function to be called in both the catch & finally blocks, and have them executed in reverse order (of appearance in the try block).The context here is: I am doing a computation, I am allocating some resources, there may or may not be exceptions. Either way, I want to release these resources once we are out of the try block.
I'm not sure what you mean? Anything in the finally expression will get executed after both the try, or the exception blocks.
It is fairly common to close resources in the reverse order from what they were opened
with-open
doesn't quite do what I want: it assumes that Ipm stuff things into a let block, and calling .close on it
but I have code where I do a glAttachShader, then want to register a "glDetachShader" even though nothing is allocated
@the2bears: you're right about catch/finally duplication ;I did not realize finally block code is auto executed by catch blocks too
My current best solution is:
(let [fns (atom [])]
(try ...
(swap! fns conj ....) ...
(finally (doseq [f (reverse @fns)] (f)))
So what you sort of need is a construct that takes a list of resources that implement a 'allocate/deallocate' protocol, allocating in order during the try, then deallocating in reverse in the finally block
Perhaps you could write a with-shader
macro, but then your code would end up being nested for each shader
I’m threading the same function like this:
I can use a reduce here like this:
Is there a simpler way to do this? It feels like there would be
I dont think that works on ->> and multiple argument functions require more work
@qqq This is polyfitting, but being lazy you can use @the2bears suggestion to have a 'allocate/deallocate' protocol
might be a bit tricky since you need to return "self" as per the docs to be a proper component
@qqq let me know what ends up working for you, I want to know how to solve this problem without going through the error part of trial and error that you will have to
trying to generate a pom with clj. clj -Spom -A:dev
fails, but clj -Spom -R:dev
works.
clj -A:dev
works also
Trying to understand why, even though -R
is good enough
are you on latest version?
does clj -Sverbose
report version 1.9.0.375 ?
I think this was actually fixed in the latest version
-Spom is a totally different code path. It’s goal is to build a pom with top-level libs in it, not to build a classpath. So it doesn’t do all the same modifications that aliases do when they resolve-libs and build-classpath. It does try to apply some modifications like :extra-deps and :override-deps on the top-level libs, but these are done via different code entirely.
.358, will try new version later
yeah, the -A aliases were being ignored during -Spom before and that was fixed in 375
I have extra deps in an alias that I want in pom
that’s ok - those should be added
assuming you’re using :extra-deps
Lifecycle is copied from component, with-component is just a slightly modified with-open
I think Rich is working on that
he did a talk about it https://www.youtube.com/watch?v=dQw4w9WgXcQ
sorry, I’m about 19 days behind
I don’t troll often…. but when I do…
Thank god I live in germany. The video is not available here. For once and for all our almighty ruler, the content industry, has saved me 😄
Here I’ll sing it for you…
Whats is the state of clojurescript on nodejs? I want to do some system scripting but clojure startup time is too slow
@pablore people are doing it, I believe. Planck and Lumo are good entry points, but the latest cljs.main
work makes it pretty easy to launch a nodejs process as well.
Hi all, I'm just starting a basic server using http-kit. It looks like even when the server's just idling the heap size increases; is this normal? I don't have much experience with java outside of school homework
the thing about the people in the clojure community that really sets it apart is that in all of my time being a part of it, no one has ever given up on me or let me down. it's not the kind of community where people run around and hurt one another.
thanks @alexmiller for setting such a great example
that's so mean @bronsa consider yourself banned (although maybe not as mean as subtly rickrolling everyone in here)
@squarenegative Yes, that's pretty normal. We have processes that, even when they're completely idle, show a sawtooth graph in memory usage. When the heap gets 70-80% full, you'll see a full GC (so heap usage drops, but overall system memory will not -- the JVM doesn't return memory to the host in general).
When a process is getting a lot of activity, it'll also do GC more often. And it'll also depend on which GC you're using. We use the G1 collector for, in theory, more consistent response times in a web app. For a very active process, the GC will be nearly continuous and you'll see heap usage going up and down a lot but in a much smaller window, often in the 40-60% range.
yeah, I was just testing using g1 and it seemed the heap size increased much more slowly
For example, here's a fairly idle process https://www.dropbox.com/s/z36ks6m1gjy7ikm/Screenshot%202018-04-20%2010.32.03.png?dl=0
And here's the same process on a different server running under load https://www.dropbox.com/s/265w1l7vui9z2cm/Screenshot%202018-04-20%2010.33.18.png?dl=0
(it's an http-kit REST API)
@seancorfield What do you use for getting those metrics and generating the graphs?
New Relic. We love it! I blogged about how to add trace annotations to Clojure code, and also some stuff about startup time... https://www.google.com/search?q=site%3Aseancorfield.github.io&q=new+relic (should be top two results)
@seancorfield awesome, thank you very much
Is there a way to destructure namespaced keywords automatically with the current namespace?
(let [{:keys [without.this.namespace/a without.this.namespace/b]} {::a 1 ::b 2}]
[a b])
Awesome, thanks! Could we get this documented at https://clojure.org/guides/destructuring?
it’s documented in the reference page
actually, maybe it’s not
https://clojure.org/reference/special_forms#_map_binding_destructuring is the place I’m thinking of
Yeah, I'd looked there too.
oh…. I wrote a whole updated section for this page
and never got it finalized with Rich
wow, I wonder where I put that :)
Thanks
:thumbsup:
New Relic. We love it! I blogged about how to add trace annotations to Clojure code, and also some stuff about startup time... https://www.google.com/search?q=site%3Aseancorfield.github.io&q=new+relic (should be top two results)
New Relic monitors all sorts of stuff, not just memory/heap. It can show you performance of database queries etc, response times for the web apps (although http-kit is not fully supported so you don't get full web app monitoring), and external calls (e.g., to payment gateways etc).
We also have it monitoring our background processes and tracking metrics in those (I need to write up how that's done -- mostly you start a thread with the New Relic agent and tell it which function to call for "probing" your app, and you track metrics and send them to NR in that function).
It can also monitor servers: disk, CPU, RAM, I/O, availability. You can also tag deployments from your build script and so New Relic can track performance comparatively for each new deployed build.
It also has JS you can use to instrument the front end of your apps. It's pretty comprehensive as a monitoring/health system.
is there a good library to help with repl debugging, such as viewing local values and such?
oooh, thanks
@U61HA86AG That's really cool; thanks.
Also take a look at http://bpiel.github.io/sayid/
I have seen that. I keep meaning to look into it more.
@seancorfield for a boot.profile is middleware the plugin equivalent?
This is REPL middleware (I assume you're talking about Sayid) so it's specific to using a REPL, regardless of Boot/Leiningen.
I guess I was referring to these instructions
{:user {:plugins [[cider/cider-nrepl "0.14.0"]
[com.billpiel/sayid "0.0.16"]]
:dependencies [[org.clojure/tools.nrepl "0.2.12"]]}}
are specific to lein's profile.cljwasn't sure the boot.profile equivalent to the plugins section
https://cambium.consulting/articles/2018/2/8/the-power-of-clojure-debugging This is a good article.
@U1CUUKHDL Ah, sorry. I haven't used Leiningen for a long time. That's not what I was expecting to see from Sayid, when I read its site and it talked about REPL middleware 😐 I sort of remember some other configuration that's needed for REPL middleware. Pretty sure, in Boot, all you need is to add those dependencies.
I would expect to see some configuration for the REPL itself that installs the REPL middleware... but maybe it installs itself automatically...?
@huthayfa.ainqawi performance is the major tradeoff in choosing multimethods over protocol based dispatch, so yes
it maybe be that this is a negligible performance hit on your overall program though, it really depends