This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-08
Channels
- # beginners (52)
- # boot (230)
- # cider (67)
- # clojure (166)
- # clojure-canada (1)
- # clojure-dev (91)
- # clojure-japan (6)
- # clojure-korea (1)
- # clojure-russia (2)
- # clojure-uk (10)
- # clojurescript (222)
- # core-async (27)
- # datomic (5)
- # editors (13)
- # euroclojure (12)
- # ldnclj (10)
- # off-topic (12)
- # om (16)
- # onyx (4)
- # other-lisps (2)
- # overtone (1)
- # re-frame (4)
- # sim-testing (1)
@aengelberg: you’re right about the evil nil case. I created an issue earlier: http://dev.clojure.org/jira/browse/CLJ-1775
Actually, I believe I am wrong about the evil nil case... (any? #(nil? %) [nil])
would return true for your trivial example. Because some
returns the truthy value of the function call.
ew. that's not what i thought pasting the link would do
@lucien.knechtli: ah, i meant a case like: I started a repl session, I changed HelloWorld
after started repl, now I would like to reload it without restarting repl.
scroll down to "reimport" in the readme for the repo
Isn't that what you're describing?
You could also change how you're loading the class on the Java side
but yea, I'd probably just use Vinyasa, because changing the way you load the class means messing with your deployed code, whereas vinyasa doesn't.
"clojure repl reload java class"
vinyasa was pretty much the only useful thing I got out of the search though
although, Chriz Zheng's blog looks like it's gonna be some good reading in case I get bored at work today: he wrote vinyasa
Hey guys. Any chance anyone knows if there is something like reduce-indexed function (like standard map-indexed)? I don't know the whole standard library, but hope there is something that I can use without implementing it myself. Thanks.
Hi, has anyone run into namespace corruptions on :reload? I kept getting my defs corrupted when reloading namespaces with Cascalog, and my colleagues inform me this is not unique in Cascalog and happens in normal Clojure code as well.
sgerguri: one common problem is that you have references from other namespaces to old instances of functions of the reloaded ns.
@ordnungswidrig: In my case I def-ed a Cascalog query.
Getting the results out of it multiple times prior to reload worked just fine, but reloading - even unrelated funs - corrupted it.
sgerguri: make sure that any ns the uses the ns with the query is reloaded, too
ivanbokii: you can do sth like (->> [1 2 3] (map-indexed identity) (reduce (fn [s [i x] (+ s (* i x)) 0)))
I didn’t reload ‘foo.core, since the definitions I had there were all done manually.
sgerguri: maybe one of the references closed over a value from foo.x.y
Folks, why we have reduce-kv
function when we could use reduce
with destructing?
(reduce (fn [acc [key value]] ...
@ordnungswidrig: thanks!
it avoids constructing, then tearing apart, the map entry
reduce-kv just walks over the internal nodes of the map and applies the function directly
devn: perhaps you were getting a logging impl from some lein plugin, and never actually depended on one properly in your project?
devn: the java loggers are very interface / impl decoupled, and everything avoids forcing a specific impl, you should usually end up having to pick one for every project
should unless someone else was poorly behaved and forced one on you
@noisesmith: there was commons logging, log4j, and slf4j-log4j12 transitively finding their way in via deps. i am using logback.
if your log library isn't working, you don't have enough of them
that's the java way
anyway, the real solution was to not have src/user.clj
there, and specify dev
in my :dev profile src-paths
yeah i've ended up just changing the ns name to not-`user`, due to https://github.com/clojure/clojure/blob/35563c1d64406ce9c57e93a3d1d83cbd0a21bbab/src/jvm/clojure/lang/RT.java#L453-L473
for situations where :prep-tasks
needs to prepare things that my main component ns needs, because the app itself depends on them, which loads clojure to run the :prep-tasks
, which loads RT.java, which loads user
anyone here use different logback configurations in dev/test/prod? actually, in general: I could use some help with logging garbage. how the heck do you manage all of these logging deps?
I like to have a separate “script” for packaging for deployment. If the app is invoked via a shell script, I just pass in -Dlogback.configurationFile=/path/to/prod/logback.xml for that.
For testing, I think you can do something similar inside leiningen. Some sort of fixtures thing. I’ve used that to hide all logging when running tests.
also, it would seem that logback.configurationFile is only being respected when I run the jar
:profiles {:uberjar {:aot :all}
:test {:jvm-opts
["-Dlogback.configurationFile=test/resources/logback.xml”]}
For production, I have a separate logback.xml elsewhere. I use that for running the jar (as you said).
For testing, I have another logback in the test/resources dir, which doesn’t get on the classpath.
And, yeah, you have to add other slf4j nonsense to bridge dependencies that use something else and won’t shut up … sometimes.
So, the “prod” logback is NOT in the jar. (Otherwise, ops folks can’t fiddle with it.)
Yeah. I’m opinionated in that I like to make a separate project for building-for-production.
It just checks out the code (or whatever) and adds production style scripts, update.d, launchd, configs, logback, whatever.
Place I worked wrote software to deploy at customer sites, so had to have logback external to a jar so support could turn stuff on to see what happened.
meh, if it works, it works -- i dont want to pass a bunch of "necessary" nonsense logging-related burden onto other devs
Ops should be able to pass in overrides as they need. It’s not a build-time concern.
paths matter to me as well -- would rather not have local devs forced into making /var/log/foo/bar.log with correct permissions
so, configuration. I'm using environ
, which lets you refer to ENV vars and java system properties in your clojure code like (get configuration :foo)
, but in prod you set the ENV var as FOO=123 java -jar ...
this turns out to be pretty handy, but locally we've got a config.edn.example
file that specifies local defaults, which you copy to config.edn
in order for them to take effect
this was all well and good, but of course, doing AOT in an environment that /doesn't/ have a config.edn
obviously breaks, which means a bunch of complicated nonsense for the build pipeline, since it needs to go out and grab config
so i'm kind of faced with this question of: should I skip AOT and pass the values in as ENV vars when the jar is run?
My preference is to consider the build as a UI problem for devs. The mount of futzing with files is painful.
right now im not specifying :main or :aot in project.clj, doing (:gen-class) and ^:skip-aot on the ns with the -main in it
As long as you have something like (System/getenv “ENV_VAR” “default”) it doesn’t matter, right?
by for instance, specifying :main, and then creating a bootstrap clojure file that references the -main indirectly, so it won't transitively AOT your project
when you go to run locally they still have to be set somewhere, even if you get to avoid them when building the jar
this whole scenario is a bit more complicated than im letting on, and i won't bore you with details, just rubber ducking a little bit thinking about the right way to keep development easy, but also close enough to a prod environment that there aren't annoying surprises when deploying
Another thing is a “configurator” that just prints out what stuff isn’t set, so devs aren’t faced with bizarre stack traces.
Or, people start relying on stuff being there and don’t build in flexibility at the right places.
yeah, the more i think about it i think that committed, sensible defaults for configuration vars needs to happen, and for the API keys in question, a separate set of test accounts can be created which will never see prod traffic
I’ve had people just “lein run —config=/path/to/custom.edn” for dev. It’s not too bad.
and maybe...just maybe commit those as well -- there's nothing of value in them, after all
Yeah, if you separate “build for production” vs “build for dev” into separate projects, you can store the production API keys in that project.
the main thing is seeing a built uberjar run in your dev environment, for me that matters
Prod project is just shell scripts (say) and conf file that get merged into an RPM (or whatever). Not a clojure project.