Fork me on GitHub
#clojure
<
2016-08-04
>
kardan07:08:28

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?

kardan07:08:07

Ah, it’s in a the new readme - ignore me

kurt-yagram10:08:01

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?

hans10:08:06

try removing your target/ directory. not sure if that applies to boot, but with leiningen, that is usually the solution.

kurt-yagram10:08:25

found it, stupid me, had to change boot.properties.

dominicm10:08:17

@hans: boot removes the target directory for every run.

dominicm10:08:35

@kurt-yagram: Yeah, the host clojure pod can be confusing at times.

octahedrion11:08:29

what is the overhead in using a destructured map as a function parameter over the equivalent multiple-artity version ?

rickmoynihan11:08:08

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?

rickmoynihan11:08:00

also I don't like how timbre defaults to using ansi colour codes

rickmoynihan11:08:33

I've never noticed any major problems with tools.logging elesewhere - other than the java logging mess of course

kurt-yagram11:08:20

I usually use tinylog (very lightweight), sometimes with slf4j binding, sometimes not... depends on my mood, I suppose

rickmoynihan11:08:56

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

danielstockton12:08:46

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?

danielstockton12:08:52

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

dominicm12:08:51

Sounds like SSE

pyr12:08:03

@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

gnejs13:08:14

@danielstockton: I’ve no direct previous experience, but it feels like (async) queues and a circuit-breaker would be useful there.

gnejs13:08:16

Send requests to a fn using core.async perhaps, and return a promise that will contain the response (or an error)?

gnejs13:08:40

(that is - the fn would use core.async internally to decouple the http-handling from the caller)

danielstockton13:08:51

@pyr im not restricted to HTTP, didn't think of TCP actually

danielstockton13:08:12

@gnejs that also sounds like something to look into

gnejs13:08:07

@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.

rickmoynihan13:08:08

danielstockton: use a pooling http-client... clj-http and apache httpclient etc... should do this underneath for you

rickmoynihan13:08:20

then use a mount/component/whatever to manage that connection-pool/client as state

danielstockton13:08:13

@rickmoynihan: thats pretty much what i originally had in mind, its the managing it as state in a component that was a bit fuzzy

danielstockton13:08:47

state would be connected or not connected i suppose, havent looked into those libraries at how i can keep track of this

rickmoynihan13:08:51

I definitely wouldn't reimplement this though - IIRC HTTP does negotiation over 1.0/1.1 (1.1 reuses sockets underneath) etc...

rickmoynihan13:08:55

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

danielstockton13:08:00

yes, i think i can live with the baggage of HTTP

rickmoynihan13:08:22

or they'll block waiting for a connection in the pool to reopen ... it's often configurable

markec13:08:30

libraries usually have some “orchestration” thread, that runs in background and checks connections in the pool

markec13:08:36

if they are connected etc.

rickmoynihan13:08:46

as markec says

markec13:08:50

some libraries are supporting also, check just before pooling it from queue

markec13:08:56

or after returning in the pool

igrishaev13:08:16

When I do lein deps, it downloads only those packages that are declared in :dependencies vector. Which command may install lein ring plugin deps?

scott.haleen13:08:25

Does anyone know if there been any information about this year's Clojure/Conj?

dpsutton13:08:01

alex miller has stated no official release but mentioned december

dpsutton13:08:23

no official release yet that is

danielstockton14:08:10

to those that were helping me earlier, i found this which seems ideal: https://github.com/tonsky/net.async

Niki14:08:35

@danielstockton: don't get your hopes up, it's kind of unfinished and not actually used in any project

Niki14:08:43

just saying :)

danielstockton14:08:00

its a good source of inspiration anyhow 😉

Niki15:08:35

yes, I think the idea was right

rickmoynihan15:08:25

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

rickmoynihan15:08:57

not sure what the state of play is today though

dominicm15:08:21

IE can't SSE.

danielstockton15:08:06

I wasn't looking for a browser solution, it's s2s - http or TCP is ok

andmed16:08:44

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)

marioaquino18:08:33

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).

gfredericks18:08:25

(-> x f1 f2 (doto prn) f3 f4)

marioaquino18:08:47

@gfredericks: McLovin! Thank you!!

seancorfield19:08:03

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 🙂

hlship19:08:32

@gfredericks: clever, I always have written a tap fn for that, but no more!

gfredericks19:08:22

@seancorfield: (-> x f1 (doto (prn "WTF")) f2)

timothypratley19:08:24

if you really want to go crazy (-> 1 (doto (->> (prn "FOO")))) o_O 🙂

gfredericks19:08:41

Worst part is it doesn't work with ->>

timothypratley19:08:41

(this is not a serious suggestion)./

gfredericks19:08:57

I mean you can't (->> x f1 (doto prn) f2)

seylerius19:08:38

How about some namespace opinions: reversed domain names, or simple names?

robert-stuttaford19:08:33

i've never understood reverse domain names for nses

robert-stuttaford19:08:02

lets put everything into 3 layers of one folder inside another

mpenet19:08:39

Why choose! Reverse dn for package (project.clj, etc) and simple name for ns

seylerius19:08:49

So simplify the folder structure, but still use the full domain name in project.clj?

gfredericks19:08:08

I use reverse dns for namespaces

gfredericks19:08:33

in libraries at least

gfredericks19:08:45

because big projects inevitably have hundreds of libs' worth of namespaces mixed together

Alex Miller (Clojure team)19:08:18

if you’re writing an app that will exist in a private space, then do whatever you want

Alex Miller (Clojure team)19:08:55

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

em20:08:25

Just happened to find (symbol "") creates... a blank symbol. Is there any practical use for this?

em20:08:37

Just curious

Alex Miller (Clojure team)20:08:16

as with keywords, programmatic symbols are sometimes useful

gfredericks20:08:03

it'd have to be in a context where you don't care about serializability

dpsutton20:08:15

to prevent keyloggers from getting my passwords, I intersperse random empty strings in every password I use

sebastianpoeplau20:08:05

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?

jaccarmac21:08:54

I've seen that before, never had a reason to use it.

jaccarmac21:08:08

In my experience, writing your own Dockerfiles/docker-compose.yml isn't that bad though.

sebastianpoeplau21:08:20

@jaccarmac: do you use a particular base image like the ones at https://hub.docker.com/_/clojure/, or just any image?

jaccarmac21:08:50

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.

sebastianpoeplau21:08:45

sounds good, thanks!

seylerius22:08:55

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)?

gfredericks22:08:50

a recursive function with a lazy-seq body