This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-27
Channels
- # beginners (113)
- # calva (39)
- # cider (18)
- # cljs-dev (19)
- # cljsrn (1)
- # clojure (80)
- # clojure-dusseldorf (1)
- # clojure-finland (1)
- # clojure-gamedev (1)
- # clojure-germany (2)
- # clojure-italy (38)
- # clojure-nl (16)
- # clojure-spec (90)
- # clojure-uk (81)
- # clojurescript (28)
- # clojutre (9)
- # cursive (47)
- # data-science (4)
- # datomic (21)
- # emacs (1)
- # events (2)
- # fulcro (11)
- # graphql (2)
- # hoplon (8)
- # hyperfiddle (23)
- # jobs (2)
- # kaocha (4)
- # lein-figwheel (1)
- # luminus (1)
- # mount (1)
- # off-topic (41)
- # pathom (5)
- # pedestal (27)
- # reitit (6)
- # remote-jobs (7)
- # ring-swagger (6)
- # shadow-cljs (42)
- # spacemacs (1)
- # sql (9)
- # tools-deps (6)
- # uncomplicate (2)
- # vim (5)
Hi everyone! Has anyone encountered the java.lang.module.FindException: Module java.xml.bind not found
error after adding: :jvm-opts ...
and the [javax.xml.bind/jaxb-api "2.4.0-b180830.0359"]
dependency?
Fixed it! Adding one is fine but not both.
Anyone heard of a library that points out the slowest members in your system? (Component/Integrant) Doesn't sound hard to build, but who knows, maybe someone already has such code
was defnitely easy with robert-hooke.
If going for it, do all logging in a ns with clojure.tools.namespace.repl/disable-reload!
set
Are you aware of tufte? https://github.com/ptaoussanis/tufte I'm using this for profiling (a yada server using component)
I'm not sure something like that would have served I needed an answer to "of all my [Sierra] components, which one is the slowest"? I cannot add profiling boilerplate to every single component...
So, I have to "profile" component/start
, which code I cannot modify
did so with robert hook, so args and time
are logged
Right, that sounds like a good solution
G’day! I’ve got a question about database connections in a web application: where do I actually keep the connection? Putting it into a namespace is not so great for obvious reasons. Is it a common pattern to put it in a request object of a http framework?
@synthomat https://github.com/tolitius/mount and https://github.com/stuartsierra/component are precisely for these scenarios
ah, or one can create the connection in a “create-routes” method passing the connection down to handlers
@rahul080327 using components?
mount is an alternative that some people prefer, both have their ways of managing state.
just from contemplating the sources of “mount”: it actually “does” define a variable in the respective namespace but defers the instantiation of the actual value until you call “start” on the framework and from then on it takes care of the lifecycle
sooo technically, if I don’t need lifecycle, I would just define an atom and “assign” the connection to it from somewhere later in the code. That’s what the component framework actually does under the hood
yeah both of them make state management nicer than the manual way. Mount however tries a kinda less opinionated approach i think: https://github.com/tolitius/mount/blob/master/doc/differences-from-component.md#differences-from-component
IIRC Mount has the drawback of failing to create isolated systems that can be run independently e.g. what if I want to parallelize my test suite? All tests would share the same stuff
I (and my team) bounced off duct, and by extension integrant, pretty hard. I strongly suspect component would be the same story, but it's been years since I last tried it out. FWIW we migrated everything duct/integrant to mount in an hour and the productivity boost that we have seen from doing that has been incredible. I find mount more amenable to just starting a part of the system, which means I can now do REPL-driven development inside the namespace I am writing, as opposed to somewhere else, followed by shipping it out when I'm done. In short, I just find mount to be a lot closer to rolling plain Clojure without any of this stuff than the other two.
Honestly that sounds like a classic simple vs. easy contrast. I absolutely do repl-driven dev with Component. Everyone else in the team does, and it's a diverse one (vim, emacs, cursive...) Component/Integrant make things explicit + testable, similarly the Reloaded workflow forces you to keep things pure and non-cyclic 🙂 It wasn't entirely an easy journey, here are some notes taken https://github.com/reducecombine/rehardened
Your mileage may vary. We use component heavily at work and are happy with it. But I like what I read about Integrant, seems better
I agree, but my conclusion is opposite to yours - I view mount
as simple, and integrant/component as complex. It just so happens that in this case, it is "made easy" as well.
Like you say, your mileage may vary.
I try to avoid controversy, but it might be helpful to wonder "I say x is complected, but it complects what with what? Is it a complection or a composition?" Mount appears to complect namespaces with state. You cannot take a namespace without also taking its state, and vice versa. Other libraries keep those orthogonal: I can create state (e.g. new app instances) without creating namespaces, That's the magic of Rich's discourse: he pursues an objective definition of simplicity, enabling more fruitful discussions 🙂
One is pure, the other is not. Sure it's more work to handle when pure, but that's also more powerful (testing/repl etc). Same argument can be made for functional programming and here we are, using clojure, so you might as well embrace (relative) purity. And you're free to use whatever you want, the rest is just subjective arguments (simplicity etc).
On a side note, that would be cool to have first class namespaces but that's another subject
would you have any links to share about first class namespaces @U050SC7SV ?
not really, it's not a thing in clojure, racket has something like that and ocaml functors come to mind (somewhat)
@U050SC7SV I think you are confusing purity with functional programming. With mount we still have pure functions. The point of FP is pure functions, not pure namespaces - since namespaces are just groupings of things. Whether said groupings contain state or not is, in my humble opinion, completely beside the point of writing pure, stateless functions. State needs to live somewhere. I don't think it matters whether it's spread across the place or living in a single namespace if you can easily get hold of it when you need it. Beyond that, it boils down to whether it forces me into a particular way of doing REPL-driven development. And my point was that mount allows me to do it any way I like, unlike the alternatives.
I like to be able to pass my state around, have multiple versions of it etc, you like to shove it at the namespace level, so be it.
I see, my original question has no clear answer, there’s some controversy about where to keep the state 😄
I think the suggestion would be to try both mount
and one of component
/`integrant` and find out which one fits you better.
https://docs.racket-lang.org/guide/units.html is this the feature you had in mind @U050SC7SV ?
https://gist.github.com/leonoel/e933ee2b3f1e627063ab1db90d5396f9 While reading the manual I've written a clojure implementation of the example, with injure Feel free to comment
which kafka client you are using guys in production ?
With a thin wrapper we wrote around the bits of it we need to make interacting with it more 'Clojureish'
@abdullahibra We use https://github.com/dvlopt/kafka.clj which is a thin wrapper around the Java one. It even supports the Kafka Streams stuff, should one desire to use it.
great thanks guys
Announcing ClojuTRE 2019, September 26-27th in Helsinki, Finland. Tickets are on sale, get yours now from https://clojutre.org/2019/
Is there any library out there with some kind of let-debug
that prints a debug statement after each let? 😛
there's a dlet explained at https://cambium.consulting/articles/2018/2/8/the-power-of-clojure-debugging
I think there are some libs out there with stuff like this, but I'm not sure which ones off the top of my head
here’s my shot:
(defmacro letd [bindings & body]
(let [pairs (partition 2 bindings)
dbg (map (fn [[v value]] `(_# (println ~(str ">>" v) ~value))) pairs)
intv (interleave pairs dbg)
bs (into [] (apply concat intv))]
(println dbg)
`(let* ~(destructure bs) ~@body)))
my solution does not work with destructuring 😢 tks @alexmiller
(defmacro let-debug
[bind-vec & body]
(let [parted (partition 2 bind-vec)
new-bind (reduce
(fn debugger [aggr [name value]]
(conj aggr
name value
'_ `(println ~(str name " is ") ~value)))
[]
parted)]
`(let ~new-bind ~@body)))
There doesn't seem to be a channel for clojure.java.jdbc
, so a simple question here. I need to write some code that will be generating a ton of very postgresql specific DDL. Without meaning to slight clojure.java.jdbc/create-table-ddl
, it is nowhere near prepared to deal with schema entity references, quoted identifiers for table or column ids, and the many many options for create table
. Even something as simple as a column default constraint requires special quoting to use create-table-ddl
, e.g. [:text-col :text :default "'the default value'"]
(note inner single quotes).
I'm just wondering if someone has written an abstraction like create-table-ddl
that is more capable with regard to supporting the many options of CREATE TABLE
. If not I suppose I'll just be concatenating up a lot of strings, no time to write this dreamed-of abstraction now.
@dave.tenny - There's also #sql, FYI.
On a side note, I was kind of suprised when I couldn't find a nice package that encapsulates queries on the the supposed-SQL-standard "information schema" supported by postgresql.
(as in, return maps of maps that represent schemas/tables/columns etc in a hierarchical view)
> There doesn't seem to be a channel for clojure.java.jdbc
, so a simple question here.
The #sql channel is for clojure.java.jdbc
discussions, as well as general SQL questions (and also other SQL libs).
I am trying to do some calls to https with http-kit/client , but all I get is " :message "HTTPS is not supported". What http-client lib do you guys use for async-http-requests? I need to use ssl with pkcs12
I am on the latest version of Http-kit. I tested Clj-http before but I did not like the async-connection-manager
aleph has a client iirc
it has its own setup for async (manifold) which is similar to core.async in some ways
i'll have a look, thanks 🙂
awh yeah. Aleph looking sweet