 (defn pick-winner-and-second-price [floor-price resps]
   ;; TODO: second price
   (->> resps
+       ;; shuffle
+       ;; sort
+       ;; take2
        (argmaxes-and-second floor-price :bidPrice)
        ;; branch the size of maxes
        (rand-nth)))




(defn gen-request [n]
  (let [c (chan)])
  (go
    (loop [i n]
      (>! c request)
      (if (< 0 i)
        (recur (- i 1)))))
  c)

(defn process [chan]
  (loop []
    (let [{:keys [req result]} (<! chan)]
      (go
        (some->> (sequence (xf (assoc options :body (json/write-str req)))
                       urls)
             (pick-winner-and-second-price (floor-price req))
             ;; log winner
             (winnotice req result))))
    (recur)))


(defn -main []
  (let [c (gen-request 1)]
      (process chan)))

(ns s7p.core
  (:require [clojure.data.json :as json]
            [org.httpkit.client :as http]
            [clojure.core.async :as a]))

(def options {:timeout 100
              :keepalive 3000})
