Fork me on GitHub
#clojure
<
2016-07-07
>
jm00:07:07

Sure, I don’t know of any talks on it yet. Still early days

Paco00:07:19

@jim: there is now s/assert

tcrawley00:07:32

@sorenmacbeth: hmm, I can see vizard-0.1.6.jar appear to be uploaded in the nginx log - would you mind filing an issue for this so we can track it? https://github.com/clojars/clojars-web/issues/new

adamkowalski03:07:33

whats your guys’ favorite library for writing a web server atm? I’m looking to learn something new!

sorenmacbeth04:07:34

@tcrawley: yes, I tried again and it worked

jm06:07:43

@adamkowalski: compojure (https://github.com/weavejester/compojure) + ring (https://github.com/ring-clojure/ring) is nice, but can take a while to set up the first time. Luminus (http://www.luminusweb.net/), which is built on top of ring/compojure is a good option if you want to get started quickly.

dominicm08:07:56

I like bidi and yada! (disclaimer: I work for Juxt. But I liked both before I came here)

mdallastella08:07:50

yada is really interesting

lvh12:07:14

Is anyone accidentally working on some clojure.spec for swagger? I am and I would prefer to contribute to existing work rather than start anew 🙂

mateus.henrique.brum13:07:19

Hey guys, I am reading the joy of clojure, and at page 279 he show us a example.

mateus.henrique.brum13:07:21

(defn respond ([exchange body] (respond identity exchange body)) ([around exchange body] (.sendResponseHeaders exchange OK 0) (with-open [resp (around (.getResponseBody exchange))] (.write resp (.getBytes body)))))

mateus.henrique.brum13:07:01

I didn't figure out this (respond identity exchange body)) and (with-open [resp (around (.getResponseBody exchange))]

mateus.henrique.brum13:07:20

Why use identity to get response body ???

lvh13:07:09

@mbrum: Not sure I understand. “around” appears to be a wrapper for the response body; identity is a wrapper that does nothing

lvh13:07:18

identity is just (fn [x] x)

mateus.henrique.brum13:07:01

I got it, it is just a extension point, and the default do nothing...

ikitommi13:07:57

@lvh: added some details/options to the issue. Please comment there if you are poking with it too. Cheers.

lvh13:07:12

@ikitommi: i started from scratch but this makes interesting points

lvh13:07:29

will comment on issue

korny14:07:52

Yo folks - anyone know of any JMS wrappers - especially ones that use JMS 1.0 / AMQP - in clojure? I looked at https://github.com/sbtourist/clamq but it’s never gotten past a snapshot release, and that was 5 years ago...

Lambda/Sierra16:07:46

@korny JMS is pretty easy to use directly.

Lambda/Sierra16:07:24

It's a surprisingly nice API, given its age.

Lambda/Sierra16:07:11

Just be careful with threads — most of the objects can't be safely used by multiple threads.

korny16:07:11

yeah, it seems most code I’ve seen uses the APIs. Once you’ve gone through the initial fiddling with factories and the like, agreed it’s not too bad.

korny16:07:20

and actually our usage won’t be too complex. I just felt dirty with the number of Java calls I was making 🙂

jasonbell16:07:02

@korny: If you are using RabbitMQ then I really liked using Langohr for AMQP stuff: http://clojurerabbitmq.info

jasonbell16:07:34

I’m 99% Kafka now so haven’t looked at it in a long while. 12 months +

korny16:07:39

Yeah, I’ve used Langohr before, it was nice. In this case we are testing a few different AMQPs, but they are all AMQP 1.0 where Rabbit chose to stick on 0.9.something

korny16:07:07

- so we’re trying ActiveMQ and Artemis and Qpid most likely

korny16:07:49

(Kafka would be nice but the client would need some very widespread changes to go away from AMQP)

manderson18:07:38

I'm implementing a Java interface and one of the methods is init where I'll need to save some state for use in the other method implementations. The generated class needs a no-arg constructor and is called by a framework, so I can't supply an atom or anything as a field on record initialization. Any thoughts on how to do this? I'm looking to do the equivalent of setting a private instance field from a constructor in Java.

Alex Miller (Clojure team)18:07:00

With deftype you can create (and set) mutable fields, but you can’t do it “on construction"

Alex Miller (Clojure team)18:07:32

but if you can construct and set the fields in init, that would work

manderson18:07:14

Yep, that's exactly what I need to do. I'll take a closer look at deftype

Alex Miller (Clojure team)18:07:19

(definterface TheInterface
  (init [])
  (getx []))

(deftype Foo [^:volatile-mutable x]
  TheInterface
  (init [_] (set! x 100))
  (getx [_] x))

(def f (Foo. 10))
(println (.getx f)) ;; 10
(.init f)
(println (.getx f)) ;; 100

manderson18:07:41

The problem here is that now Foo has a single arg constructor. The framework will attempt to instantiate this class with a no-arg ctor and it will fail because it requires an argument.

Alex Miller (Clojure team)18:07:49

ah, right. well that won’t work then. :)

Alex Miller (Clojure team)18:07:19

you can do that with gen-class, although it’s a lot more work

Alex Miller (Clojure team)18:07:30

you can implement the interface, define the 0-arg constructor, and construct the initial “state"

manderson18:07:02

Ok, that makes sense. I'll give it some more thought. Thanks Alex!

ilukinov19:07:56

how to stop ring server started with ‘lein ring server’?

rmuslimov19:07:37

You have to store somewhere result of (run-server ) and call it to stop

rmuslimov19:07:03

I suggest look first episode of this excellent intro to clojure lang http://www.parens-of-the-dead.com/

rmuslimov19:07:42

actually image on the top of this site, shows an answer for your question

rui.yang22:07:29

newbie question, whats the best way updating a vector element in a map?

rui.yang22:07:13

map contains a vector, and i want to update one element of the vector

akiva22:07:38

You’d have to pull out the vector, update the vector, then assoc it back into the map.

rui.yang22:07:41

what if it is more nested, like that vector element is a map, and that map contains another vector, do i have to go deep to change element in nested vector?

rui.yang22:07:20

sounds not ideal

akiva22:07:36

I’d be kind of alarmed at that level of complexity in a data structure but you could try assoc-in to grab the far-nested item.

rui.yang22:07:48

i remember someone has a library

rui.yang22:07:43

currently only one level, but i just wonder:simple_smile:

akiva22:07:23

With assoc-in and update-in, you can dig as deep as you need.

akiva22:07:50

Within reason, I’m sure. Heh.

madstap22:07:24

If you have some crazy nested thing you should check out specter (https://github.com/nathanmarz/specter) for that.

rui.yang22:07:46

what i want to do is to use a vector key as identifier to update a list in a map

akiva22:07:11

A vector key is simply the index of the value.

rui.yang22:07:24

key is [:model [:customers {:name "john"} :age 22]]

rui.yang22:07:44

so it is a nested vector

rui.yang22:07:05

the inner vector means a list, and i want to update the item with name john, and assoc its age key with value 22

rui.yang22:07:44

so the map in the inner vector means a filter condition

rui.yang22:07:18

@madstap thanks, thats the lib in my memory

rui.yang22:07:51

its kind of a custom dsl

rui.yang22:07:31

the target map will be {:model {:customer [{:name "john" :age 21}]}}

rui.yang22:07:08

sorry the vector should be a vector of a map

akiva22:07:07

Yeah, you could do something like (assoc-in m [:model :customers 0 :age] 22).

akiva22:07:16

Oops, didn’t see you wanted to search on :name.

nathanmarz22:07:01

looks like this with specter:

(setval [:model :customer ALL #(= (:name %) "john") :age]
  22
  {:model {:customer [{:name "john" :age 21}]}})
;; => {:model {:customer [{:name "john", :age 22}]}}

rui.yang22:07:39

@nathanmarz awesome, will try it out, thanks!

nathanmarz22:07:05

sure thing, feel free to come by #C0FVDQLQ5 channel if you have questions