This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-28
Channels
- # bangalore-clj (1)
- # beginners (67)
- # braveandtrue (179)
- # cider (28)
- # cljdoc (1)
- # clojure (132)
- # clojure-conj (3)
- # clojure-dev (1)
- # clojure-finland (6)
- # clojure-nl (2)
- # clojure-russia (6)
- # clojure-spec (19)
- # clojure-uk (62)
- # clojurescript (90)
- # clojutre (5)
- # component (2)
- # cursive (30)
- # data-science (1)
- # datomic (42)
- # duct (9)
- # emacs (1)
- # figwheel-main (158)
- # fulcro (57)
- # funcool (3)
- # hoplon (1)
- # jobs (17)
- # mount (38)
- # off-topic (15)
- # re-frame (53)
- # remote-jobs (2)
- # schema (11)
- # shadow-cljs (299)
- # spacemacs (25)
- # specter (2)
- # tools-deps (54)
- # vim (11)
- # yada (6)
anybody know a good circuit-breaker library for clojure? I've tried to use Hystrix wrapper but it's not quite compatible with my use case
@hawari.rahman17 what do you mean by circuit breaker?
I'm smiling happily! I just found a useful little function that's been in Clojure since 1.0! not-empty
.
The name is not wonderful (IMHO), but it will clean up a lot of my string manipulation and javascript interop code.
@saikyun I want to set up a mechanism so that whenever one of my application dependencies hang (usually another service), it should fail gracefully with some sort of fallbacks
Hystrix is one of good example of what I want to do. Currently what I have is just a simple timeout and retry limit to a network call.
If a service seems to be inactive, the app shouldn't bother to do any request to that service at all.
@hawari.rahman17 oh, I see 🙂 I thought you meant on a function level, not application level.
No problem, I've actually found some libraries like https://github.com/sunng87/diehard, I just want to ask around for opinions on this topic
I had posted the query a day back and I thought it had started working on its own, but I found what the real issue is
Exception in thread "Thread-1" java.io.IOException: Cannot run program "/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home" (in directory "<elided>): error=13, Permission denied
Wait, JDK 11? Is that even released yet?
if you type echo $JAVA_HOME
what do you get?
$ /usr/libexec/java_home -V Matching Java Virtual Machines (3): 11, x86_64: "Java SE 11-ea" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home 9, x86_64: "Java SE 9-ea" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home 1.8.0_112, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
$ lein repl nREPL server started on port 49454 on host 127.0.0.1 - <nrepl://127.0.0.1:49454> REPL-y 0.3.7, nREPL 0.2.12 Clojure 1.8.0 Java HotSpot(TM) 64-Bit Server VM 11-ea+8 Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) Javadoc: (javadoc java-object-or-class-here) Exit: Control+D or (exit) or (quit) Results: Stored in vars *1, *2, *3, an exception in *e user=>
So currently I am simply starting it like that, and connecting from Cider on Emacs... but it's very irritating
I think the first thing I’d do is point JAVA_HOME back to jdk-8, looks like the others are Early Access
Yeah, get the stable version working first, then once the environment is reliable, play with the EA stuff
$ lein repl Exception in thread "Thread-1" java.io.IOException: Cannot run program "/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home" (in directory "<elided>"): error=13, Permission denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:620)
What’s your JAVA_HOME now, exactly?
I am beginning to think this is some strange config issue with macOS, or maybe my mac with leiningen?
Something definitely seems odd
Actually, I think if it were me, I’d try deleting leiningen and re-installing it
I set it in my .bashrc ... for lein, I have set it in the ~/.lein/profiles.clj ... do you think removing that profiles.clj
file might be worth a try?
Yeah, actually maybe move the profiles.clj file to disabled_profiles.clj for a bit
before re-installing lein
Okay, let me try that and see... and btw, if this helps, I installed leiningen using homebrew
Hmm, never tried using homebrew to install leiningen
$ lein repl #error { :cause Don't know how to create ISeq from: java.lang.Character :via [{:type java.lang.IllegalArgumentException :message Don't know how to create ISeq from: java.lang.Character :at [clojure.lang.RT seqFrom RT.java 542]}] :trace [[clojure.lang.RT seqFrom RT.java 542] [clojure.lang.RT seq RT.java 523]
if moving profiles.clj out of the way doesn’t help, I think I’d use brew to uninstall lein, and then reinstall it with the instructions from http://leiningen.org
Phew... that worked at last! 🙂 ... I installed the lein
script for that link and now lein repl
works fine, and I can use Cider to spawn the REPL... thanks for your help, mate!
I'm using Cursive. If I load a Clojure namespace in he repl and it requires another namespace, it works just fine. If I load a Clojurescript namespace that requires another Clojurescript namespace it won't resolve unless I first load the required namespace manually. Is it supposed to work like this or am I doing something wrong?
Is there an existing, easy way to read a csv (with a header) into a coll/seq of maps (keys defined by column names)?
https://github.com/davidsantiago/clojure-csv or https://github.com/clojure/data.csv
org.clojure/data.csv
seems fine but would require a couple of extra steps to wrangle it into the format I’d like. Seems like it’s probably something other people have come up against and solved already?
Thanks @seancorfield
Has there been any discussion involving contributions to this repo: https://github.com/danistefanovic/build-your-own-x
I think it’s a great opportunity to showcase clojure in different use cases
Greetings, I’m new to clojure and I’m looking at the java.jdbc library. I’m trying to validate a jdbc connection string like “jdbc:<mysql://root:@localhost:3600/som>” but I can’t seem to find the best way to do it with the current version of java.jdbc. I’m following the O’Reilly Clojure book and the chapter (14) on jdbc mentions that the function jdbc/with-connection would do the trick. Unfortunately, I can’t seem to locate that api in org.clojure/java.jdbc “0.7.8". Is there a recommended way to validate a jdbc connection string?
Right now I’m using a trivial query to validate a db-spec:
(def db-spec {:classname "com.mysql.cj.jdbc.Driver"
:dbtype "mysql"
:dbname "som"
:user "root"
:useSSL false
:password ""})
(deftest test-connection
(testing "a local connection using db-spec"
(is (= 15 (:result (into {} (jdbc/query db-spec ["SELECT 3*5 AS result"])))))
)
)
However, passing the connection string will throw an exception:
(deftest test-connection2
(testing "a local connection using db-conn"
(is (= 15 (:result (into {} (jdbc/query db-conn ["SELECT 3*5 AS result"])))))
)
)
Exception looks like:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException (SQLError.java:174)
com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException (SQLExceptionsMapping.java:64)
com.mysql.cj.jdbc.ConnectionImpl.createNewIO (ConnectionImpl.java:832)
com.mysql.cj.jdbc.ConnectionImpl.<init> (ConnectionImpl.java:456)
com.mysql.cj.jdbc.ConnectionImpl.getInstance (ConnectionImpl.java:240)
com.mysql.cj.jdbc.NonRegisteringDriver.connect
Are you sure you have the right port in your connection string? MySQL is usually listening on port 3306 not 3600.
I think I have a partial answer to “Where did with-connection go?” right here: https://stackoverflow.com/questions/22586804/with-connection-what-happened