Fork me on GitHub
#yada
<
2016-09-15
>
kingoftheknoll03:09:55

Evening everyone! I have a question about the swagger integration. I don’t see anything about what messages are returned to the consumer of the API. For example, if I return the json below I would want to display in swagger that you’d receive a; array of maps with count and modified_date keys.

[
    {
        "count": 556,
        "modified_date": "2016-09-12"
    },
    {
        "count": 1,
        "modified_date": "2016-09-14"
    }
]

kingoftheknoll04:09:19

Looking at the ring-swagger stuff it looks like you can include a :schema key with a Plumatic Schema to the :responses key for a particular status code.

kurt-yagram06:09:46

I was trying to get SO_REUSEPORT to work. The aim is to have zero-downtime deployment. As far as I understand, using SO_REUSEPORT, one can have two (or more) applications listening to the same port (without having a Address already in use-issue). So:

(ns ...
  (:require ...
    [aleph.http :as http]
    ...))
...
 (let [http-server (http/start-server
                     (bidi/make-handler api)
                     (conj (::http config)
                           {:bootstrap-transform
                            #(doto %
                               (.option ChannelOption/SO_BROADCAST true)
                               (.option EpollChannelOption/SO_REUSEPORT true))}))]
    (netty/wait-for-close http-server)))
Just very quick questions: did anyone try to get SO_REUSEPORT to work (with yada/aleph/netty in clojure)? Did it work? How did you do it 🙂? (http://marrachem.blogspot.be/2014/09/multi-threaded-udp-server-with-netty-on.html , https://sam.andrews-home.com/post/netty-doesnt-suck-at-udp-servers)

dominicm18:09:55

@kurt-yagram: my memory of reuseport (from C sockets) was this: If I started a server too quickly after killing the old one, the kernel wouldn't have released it. But I don't remember it allowing parallel listeners. Who's response wins?

kurt-yagram18:09:58

Well, I thought it would be like a kind of load balancing, but apparently, it doesn't work like that. I mean, it doesn't seem to be possible to make 2 applications listening on the same port (and the os taking care of dispatch/choosing one).

kurt-yagram19:09:47

I'm implementing sse with yada. All seems to work fine, except, yada prepends data: to all messages. This would be fine, if sse message only have a data:-field, which is not the case. They also accept retry, id and event-fields. Can this be configured somewhere? I'd like to send messages like:

id: <message-id>\n
data: whatever\n\n

malcolmsparks20:09:35

Hi @kurt-yagram - trying providing your own defmethod for text/event-stream, taking the existing code as a template.

malcolmsparks20:09:43

That way you'll have full control. The current implementation works as a HOWTO. Yada is declarative to a point, but beyond it's programming that takes over.

kurt-yagram20:09:36

allright 🙂