This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-04
Channels
- # arachne (1)
- # beginners (41)
- # boot (92)
- # capetown (8)
- # cider (10)
- # cljsjs (4)
- # cljsrn (42)
- # clojure (94)
- # clojure-india (1)
- # clojure-russia (48)
- # clojure-sanfrancisco (1)
- # clojure-spec (34)
- # clojure-uk (13)
- # clojurescript (29)
- # cursive (12)
- # datavis (4)
- # datomic (10)
- # dirac (63)
- # editors-rus (16)
- # emacs (57)
- # funcool (5)
- # hoplon (22)
- # jobs (2)
- # lein-figwheel (3)
- # leiningen (5)
- # onyx (51)
- # other-languages (2)
- # proton (1)
- # protorepl (2)
- # re-frame (34)
- # remote-jobs (1)
- # sfcljs (5)
- # spacemacs (1)
- # specter (2)
- # sql (20)
- # test-check (54)
- # yada (1)
I’m trying to upgrade a duct app from 0.5 to the new 0.8 where generators seems to have disappeared. I can’t find much info in the readme, anyone got a tip on how to generate an endpoint, component or the new boundary protocol?
I'm want to give clojure.spec a try. I'm using boot and have
(set-env! :dependencies '[[org.clojure/clojure "1.9.0-alpha10"]]
When I add (require '[clojure.spec :as spec])
I get java.io.FileNotFoundException: Could not locate clojure/spec__init.class or clojure/spec.clj on classpath.
Where's clojure.spec gone?try removing your target/
directory. not sure if that applies to boot, but with leiningen, that is usually the solution.
found it, stupid me, had to change boot.properties.
@kurt-yagram: Yeah, the host clojure pod can be confusing at times.
what is the overhead in using a destructured map as a function parameter over the equivalent multiple-artity version ?
We have a bunch of clojure projects... some use timbre for logging (others clojure.tools.logging)... I've recently had some problems with timbre losing important stackframes from logs (thanks to pretty) and also printing concurrent log entries over each other in production. So thinking we should just switch to tools.logging everywhere with slf4j and a log4j backend (some java libraries - we use and contribute to log in log4j) - What does everyone else use?
also I don't like how timbre defaults to using ansi colour codes
I've never noticed any major problems with tools.logging elesewhere - other than the java logging mess of course
I usually use tinylog (very lightweight), sometimes with slf4j binding, sometimes not... depends on my mood, I suppose
yeah I've often just gone with whatever was there - because so long as it works - who cares - but timbre seems to be causing me some pain - so planning on switching
can anyone share their standard approach to handling persistent http connections between services? for example, how do you handle the case when the server closes the connection?
in other words, i want to establish a connection once and then ensure it stays alive, reconnecting or throwing an error if it gets disconnected
@danielstockton: if you are sure you want to use HTTP and not TCP for this, then either websockets or SSE will allow you to do this. If possible for your use-case, a plain TCP connection will also nicely do the trick
@danielstockton: I’ve no direct previous experience, but it feels like (async) queues and a circuit-breaker would be useful there.
Send requests to a fn using core.async perhaps, and return a promise that will contain the response (or an error)?
(that is - the fn would use core.async internally to decouple the http-handling from the caller)
@pyr im not restricted to HTTP, didn't think of TCP actually
@gnejs that also sounds like something to look into
@danielstockton: imo a pattern like that should be necessary even without a persistent http-connection. Connectivity can be shaky even for one-connection-per-call scenarios.
danielstockton: use a pooling http-client... clj-http and apache httpclient etc... should do this underneath for you
then use a mount/component/whatever to manage that connection-pool/client as state
@rickmoynihan: thats pretty much what i originally had in mind, its the managing it as state in a component that was a bit fuzzy
state would be connected or not connected i suppose, havent looked into those libraries at how i can keep track of this
I definitely wouldn't reimplement this though - IIRC HTTP does negotiation over 1.0/1.1 (1.1 reuses sockets underneath) etc...
well depends if you care whether its connected or not... usually you use those libraries because you don't want to know... you just want it to work... If it can't work the libraries will raise an appropriate error when you try and send
yes, i think i can live with the baggage of HTTP
or they'll block waiting for a connection in the pool to reopen ... it's often configurable
libraries usually have some “orchestration” thread, that runs in background and checks connections in the pool
as markec says
When I do lein deps
, it downloads only those packages that are declared in :dependencies
vector. Which command may install lein ring plugin deps?
Does anyone know if there been any information about this year's Clojure/Conj?
ok thanks
to those that were helping me earlier, i found this which seems ideal: https://github.com/tonsky/net.async
@danielstockton: don't get your hopes up, it's kind of unfinished and not actually used in any project
its a good source of inspiration anyhow 😉
danielstockton: sorry I was assuming you wanted plain HTTP - not long-poll/SSE/websockets... When I last looked at SSE (about 3 years ago) it was inconsistently supported across browsers - websockets was more reliable... though I much prefer the idea of SSE to websockets for most usecases
not sure what the state of play is today though
I wasn't looking for a browser solution, it's s2s - http or TCP is ok
user=> (source integer?)
(defn integer?
"Returns true if n is an integer"
{:added "1.0"
:static true}
[n]
(or (instance? Integer n)
(instance? Long n)
(instance? clojure.lang.BigInt n)
(instance? BigInteger n)
(instance? Short n)
(instance? Byte n)))
Would not abandoning docs altogerher in fns like this, make life easier to everyone. No docs - see the code. Clear message. Otherwise it is just misleading (and yes, i notice small i in integer)Is there a form of prn
/`print`/`println` that is friendly for using in thread-first/last macros? I’d like to print a value somewhere in the middle of a series of calls and have the function return the original value so the printing can be transparently inserted anywhere. It’s easy enough to write, but I wondered if there was already a standard function that did what I wanted (and that I was unaware of).
@marioaquino use doto
(-> x f1 f2 (doto prn) f3 f4)
@gfredericks: McLovin! Thank you!!
Oh, that is very neat @gfredericks ! Thank you! And (-> x f1 f2 (doto (partial println "message")) f3 f4)
if you want to print a labeled debug message I guess… Nice! That’ll save me constantly writing temporary debug
and spy
functions everywhere 🙂
@gfredericks: clever, I always have written a tap
fn for that, but no more!
@seancorfield: (-> x f1 (doto (prn "WTF")) f2)
if you really want to go crazy (-> 1 (doto (->> (prn "FOO")))) o_O 🙂
Worst part is it doesn't work with ->>
(this is not a serious suggestion)./
I mean you can't (->> x f1 (doto prn) f2)
i've never understood reverse domain names for nses
lets put everything into 3 layers of one folder inside another
indeed 🙂
So simplify the folder structure, but still use the full domain name in project.clj?
I use reverse dns for namespaces
in libraries at least
because big projects inevitably have hundreds of libs' worth of namespaces mixed together
if you’re writing an app that will exist in a private space, then do whatever you want
if you’re writing a public lib, either reverse dns (but com/org/net not necessary) or some other “owned” term (like a copyrighted name) is sufficient as well
Just happened to find (symbol "")
creates... a blank symbol. Is there any practical use for this?
I doubt it
as with keywords, programmatic symbols are sometimes useful
it'd have to be in a context where you don't care about serializability
to prevent keyloggers from getting my passwords, I intersperse random empty strings in every password I use
does anyone use https://github.com/palletops/lein-uberimage or know a good alternative for automatically packaging up a clojure app in a docker container?
In my experience, writing your own Dockerfiles/docker-compose.yml isn't that bad though.
@jaccarmac: do you use a particular base image like the ones at https://hub.docker.com/_/clojure/, or just any image?
Haven't had a Clojure project I've used Docker on, but in general I'll look for the official image for the basic environment I'm trying to target. At first glance, that official image looks fine if you're using lein for your project. If you just want to deploy an uberjar, I would look to use a ligher-weight image with only the JVM you want to target or even an Alpine image that you load with a JVM yourself.
sounds good, thanks!
What's the best way to build a lazy sequence from a producer function (calling an API) that wants to know the length so far and an attribute of the last item, and will eventually run dry (probably returning nil
)?
a recursive function with a lazy-seq
body