This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-22
Channels
- # bangalore-clj (6)
- # beginners (110)
- # boot (49)
- # cider (13)
- # cljs-dev (35)
- # cljsrn (5)
- # clojure (145)
- # clojure-conj (3)
- # clojure-dev (60)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-russia (3)
- # clojure-serbia (1)
- # clojure-spec (116)
- # clojure-uk (58)
- # clojurescript (235)
- # cursive (14)
- # datascript (7)
- # datomic (31)
- # dirac (144)
- # emacs (1)
- # events (1)
- # hoplon (12)
- # leiningen (11)
- # luminus (60)
- # lumo (19)
- # off-topic (18)
- # om (74)
- # onyx (5)
- # pedestal (13)
- # precept (3)
- # re-frame (3)
- # reagent (15)
- # remote-jobs (7)
- # ring-swagger (25)
- # rum (1)
- # untangled (53)
- # vim (3)
I've run into a strange compiler error that only seems to manifest when I pull in a secondary library via checkouts. I've verified the problem is not code as it works on another machine. Tried reinstalling java and Leiningen to no avail. Any idea what this could be?
user=> (require '[foo.bar])
CompilerException java.lang.ExceptionInInitializerError, compiling:(foo.bar.clj:1:1)
frameworks are things that call you, rather than things you call
(which are more likely components)
not something I made up and probably not 100% satisfying, but I think it’s about right
https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md I'm trying to deploy to private repo according to this tut, but every time I use lein deploy, It will ask for username and password. I mentioned it's said there's a bug for gpg, it that mean the username and password in credentials.clj.gpg will not work, orI have to do something?
Hey all, I am running into what I think is a bug with how clojure's java interop works
I am trying to wrap https://github.com/lokra/seaweedfs-client for use in clojure
FileSource fileSource = new FileSource();
// SeaweedFS master server host
fileSource.setHost("localhost");
// SeaweedFS master server port
fileSource.setPort(9333);
// Startup manager and listens for the change
fileSource.startup();
FileTemplate template = new FileTemplate(fileSource.getConnection());
template.saveFileByStream("filename.doc", someFile);
(defn connect!
[host port]
(let [client (FileSource.)]
(.setHost client host)
(.setPort client port)
(.startup client)
(reset! client-atom client)
(let [value (.getConnection @client-atom)]
(reset! file-template-atom (FileTemplate. value)))))
I get an error similar to
IllegalAccessError tried to access class org.lokra.seaweedfs.core.Connection from class <class info>
I have found https://groups.google.com/forum/#!topic/clojure/zr2N0dbidAI and https://dev.clojure.org/jira/browse/CLJ-1243 that seem to point to this being a problem
Plot thinkens, I can use the code without problems on my Mac but on Windows it breaks
I don't see any signs that CLJ-1243 has anything to do with it
hey guys! I want to read a stream with unknown number of lines (e.g. a file) and fire an async get request per each line (lets say using an http-kit async get with (go (>! c response))
as a callback). then, read the responses one by one into another file. is there an elegant way of closing the channel making sure I am not missing any async puts into the channel? I can do so with putting my own guard msg at the end but it feels awkward.
I'm not sure I understand what you're trying to do exactly; any reason why the producer can't just close the channel when the stream runs out?
How so? The producer being (in my mind) the single sequential process that reads from the stream and puts on the channel, it should be able to not close the channel before it's finished reading the stream
if that's the general shape and you want to ensure some parallelism in the "calls" step, maybe look at what the pipeline
functions have to offer in core.async?
Can anyone either give me some thoughts or tell me the best place to ask about some architecture issue I'm trying to sort out? Long story short, I have a Clojure + Clojurescript web app that needs to extend itself as a desktop app and as a user-owned server (with web admin api) that can have user created functions (think add-ons, plug-ins, arbitrary user code). I'm trying to find the best way to implement these two new pieces that highlights ease of installation, extensibility, minimal system requirements, and shared codebase as much as possible. The desktop app itself is surely going to end up being electron-based. As far as the code, there's a "simulation" engine that I don't want to rewrite in multiple languages unless from scratch to be shared, and is currently in .cljs files. My ideas thus far are - Option 1: Write the user-run server in Clojurescript + Node.js (running on node.js as the server) with user-defined JavaScript functions that get called from Clojurescript/JavaScript, and expose the Clojurescript API via externs Option 2: Write the user-run server in Clojure and run a v8 instance where I eval anything written by users in pure JavaScript, returning and sending json to communicate (at the cost of some speed and cruft). Any other ideas or thoughts? Or anywhere someone can point me? Thanks.
@twicebaked - Don't have time to think deeply about this now, but your question strikes me as one that could be asked at the Clojure or Clojurescript subreddit. That way it's less likely to be buried by other conversations while people think about it.
wasn’t it going to be merged in later, on a “when it’s done” kind of schedule (so after 1.9) ?
There's a good discussion about this on the latest defn podcast (https://defn.audio) - with Stuart Halloway - it's not on the website yet but it's episode 23 - it's in the RSS
the true answer is: we have not yet decided
it is effectively part of core now as Clojure depends on spec.alpha. thus users of Clojure get both. Whether and when the two units of code are co-located will depend on how things unfold (but should not actually matter to users)
Hi, I'm trying to figure out how to do something that's embarrassingly simple, but im just having no luck lol. Basically, I need something that does the following
(check #{1 2} [1 2 3]) => true
(check #{1 2 4} [1 2 3]) => false
for check i've been through variations of some, every? not-any?, etc. But still can't quite get what I'm looking for . I just need to flag the fact that there's something in the first collection that's not in the secondnot equality, just that "a has something that b doesn't" ,it's ok if b has somethign that a doesnt
so was wondering about the cost of converting from a list/vector to a set to do the comparison
(defn set
"Returns a set of the distinct elements of coll."
{:added "1.0"
:static true}
[coll]
(if (set? coll)
(with-meta coll nil)
(if (instance? clojure.lang.IReduceInit coll)
(persistent! (.reduce ^clojure.lang.IReduceInit coll conj! (transient #{})))
(persistent! (reduce1 conj! (transient #{}) coll)))))
so i guess it would be (and (subset my-set (set coll)) (not-empty? (remove my-set coll))
if the difference is empty, a is a subset of b
guaranteed
if you’re just trying to ensure a subset, can’t you just use set/subset?
https://www.conj.io/store/v1/org.clojure/clojure/1.8.0/clj/clojure.set/subset%3F ?
But disjoint sets have a non empty difference which was certainly not according to his original requirements
@dpsutton he said "I just need to flag the fact that there's something in the first collection that's not in the second" -- disjoint sets certainly seem to fulfill that requirement, as there is definitely "something in the first collection that's not in the second"
what is the "best" way to store a c3p0 pool to be accessed by multiple namespaces?
mdrago1026: You can use something like https://github.com/tolitius/mount or https://github.com/stuartsierra/component to manage complex required system dependencies.
Or for something simple like a c3p0 pool, which keeps track of it’s own errors for the most part, I tend to just use something like (defonce conn-pool (delay (create-c3p0-connection))
and everywhere else you want to refer to it you can require
the config namespace and reference the pool with @conn-pool
awesome. thanks a ton. I will take a look at these
@mdrago1026 on a very random, unsolicited side note, I prefer http://brettwooldridge.github.io/HikariCP/ over c3p0. Nothing inherently wrong with c3p0, and I’ve used it in production quite a lot, but hikariCP fits better with what I’m used to in Clojure (in terms of “it just kind of does the correct thing”)
very interesting. let me read up on this. I've heard of Hikari and simply always default to c3p0 since that's what i always have used
way more than the speed of things (which is not insubstantial), this is why I prefer hikaricp: https://github.com/brettwooldridge/HikariCP/wiki/Pool-Analysis#c3p0
wow this is neat
I'm going to try this out
Another piece of unsolicited advice: you should not think of namespaces as accessing anything; namespaces are passive collections of functions. And if a function needs access to a connection pool, it should receive it as an argument, regardless of what namespace it's in.
makes sense. I always got confused when it came to "sharing a connection" because everything else is functional and stateless, then comes the connection
I am looking for some help for code coverage tools for clojure, has anyone used cloverage before?
@payal worked fine last time I used, gave a nice report for lisp (based on forms covered)
thanks @hcarvalhoaves
just figured out why I am not able to get it..so my tests goes through all well when I do lein test, but are failing when I use cloverage
apparently they have this issue open https://github.com/cloverage/cloverage/issues/164
@mdrago1026 Use defstate
from https://github.com/tolitius/mount, or look into https://github.com/stuartsierra/component.
BTW, do you need to stick with c3p0? I enjoyed https://github.com/tomekw/hikari-cp quite a bit.
hansen-pansen: 😄 you and me? We’re on the same page, apparently…just different threads 😄
I felt quite ashamed that I sent the same advice hours later 😀
Oh, sorry for replying out-of-thread. 😳
@hansen-pansen No problem. I don't need c3p0 (used it before for work, so I just default to it). @tanzoniteblack also told me to look at hikari and it looks awesome. So thank you both
and mount and component both look great too
Is there a library that offers a worker-queue type of concurrency, i.e. enqueue work for a fixed-sized thread pool? I looked into claypoole
, but it works on sequences.
hansen-pansen: if you’re familiar with java, you can do it the same ways you would in java with clojure. If I’m not too worried about thread priorities and contention, then I’ll just use core.async with a fixed number of “workers” (i.e. go-loops) that are pulling from a shared channel, and then write jobs to that channel
I already rolled a n00b-version with core.async, but it felt … too low-level. I looked into the amazing manifold
, which offers backpressure and all the nice stream operators, but it lacks the pooling part.
Just wondering whether somebody else stumbled over the same problem.
Ohh, and I have close to zero Java background, but if that is an option, I will take a look. I guess you mean something from java.util.concurrent
?
agreed you can just use an ExecutorService
depends on your requirements. the main problem with core.async for worker pools can be that it uses the same thread pool for all core.async related channels. So if this is supposed to be a background operation, and you also use core.async in something like handling production web requests, then your background jobs might be interfering with your web requests. If that’s your case, you’ll probably want to use ExecutorService
but if you use core.async pipeline-blocking properly you can do it at a high level with clojure too
where the queue is the buffer on the chan, and the thread count is the parallelism arg
pipeline-blocking
is what I used with my n00b version.
And yes, I try to use concurrency mostly for background web requests.
Thanks to your ideas on this topic, I propably should just put more brains on the core.async/pipeline-blocking
idea and think of some error-passing messaging or channel.
https://stackoverflow.com/a/41448848/2068691 brings me to some ideas. Thank you very much for your ideas and inspiration!
:thumbsup:
Thank you very much, guys! Your help is very much appreciated. This community is so cool!
So this function reflects
(defn test-reflect [^javax.servlet.http.HttpServletResponse resp]
(proxy [java.io.FilterOutputStream] [(.getOutputStream resp)]
(close []
(proxy-super close)
(println "hello"))))
specifically the call to proxy-super reflects
and I’m wondering why
it seems like it should be possible to resolve .close()
@michaelblume I was about to make a PR with a fix for that.
beat you to it =)
ring-servlet no longer reflects, didn’t check the other subprojects
hmm, lein check runs cleanly for me with just what I have
ah, yeah
So I chose not to trust lein check
, since I can see in the source how it would be reflecting. 🙂
I’ll look into it =)
oh, you’re in the jetty adapter, I see
ah, yeah, lein check reports problems
@jeaye I also added a return type hint so my code wouldn’t reflect
That PR looks good; thanks for beating me to it and updating it for ring-jetty-adapter. 🙂
can you use environ when making a war file and deploying via tomcat? for example when i run lein with-profile dev ring uberwar...
does that do anything?
very occasionally, 'clojure.core doesn't appear in the list returned by (loaded-libs)
. that would be a bug right?
So I am using an exception tracker that has mediocre clojure support (Sentry), but I'm working to improve it. Exception "rollup" (grouping of exceptions based on their similarity) relies on the hash of "in-app" stack frames (frames that begin with com.myapp for instance) being equal to a previously seen exception's stack frames. I believe rollup is not working across runs of my application due to anonymous function names differing. So, for instance: com.myapp$fn__12345
is the name right now, but on the next run it may be com.myapp$fn__99999
. Are there other patterns in clojure stack traces beyond foo.bar$fn__12345
that I should let the maintainers know about which are specific to clojure, so exception rollup works as intended?
the way its sending the tracebacks seems to make Sentry happy (it manages to group by Exception type nicely)
@hcarvalhoaves I'm kind of meh on manually reading source files from disk with no cache and parsing the exception object by hand. This is something that can be accomplished on the server side.
As of a week ago or so, the getsentry
folks picked up coda hale's wrapper around raven-java
.
One other thing to add in case you're interested: I skipped the need to have in-app
by simply setting the package names of my app as a param on the DSN
Finally, I spoke with the sentry maintainers and they said it would be no problem to just fix the hashing of the problematic frames.
@hcarvalhoaves err maybe one more thing: I tried variations on what you're using, and I still managed to have mixed results. I fixed that same nth
IndexOutOfBoundsException
for :context_line
for instance.
Here's the "official" sentry-clj lib now -- PRs as I understand it, are welcome: https://github.com/getsentry/sentry-clj
IMO the killer feature is having source code context around the error
without that Sentry is just an expensive log aggregator