Skip to content

Instantly share code, notes, and snippets.

/asdf.clj Secret
Created Aug 10, 2015

What would you like to do?
;I have a script which makes a web request, then processes the response. I want to archive
;every web request to disk, so if I want new information in the future, I can retroactively process all the requests and catch up
(require '[clj-time.core :as t]
'[clj-time.format :as f]
'[clj-http.client :as client]
'[clojure.core.async :as a])
(defn time-string []
(f/formatters :basic-date-time-no-ms)
(defn generate-filename []
(str "resources/" (time-string) ".edn"))
;;this creates a file with the timestamp of the data then returns it
(defn make-file! [response]
(spit (generate-filename) response)
(def mk-file-xf (map make-file!))
(def c (a/chan 5 mk-file-xf))
(defn make-request []
(client/get ""))
(dotimes [n 5]
(a/put! c (make-request))
(Thread/sleep 1000))
; now the processing i do will take! from c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.