Skip to content

Instantly share code, notes, and snippets.

@gardnervickers
gardnervickers / gist:178f4c4ac0607f6275c5
Last active August 29, 2015 14:23
Read json file and parse to edn with core.async
(defn try-parse [x]
(try
(json/parse-string x true)
(catch Exception e
x)))
(defn lazy-test-data []
"Returns a channel that reads json maps line by line from mock_data.json "
(let [channel (chan 5 (map try-parse))]
(future (with-open [rdr (clojure.java.io/reader "resources/mock_data.json")]
@gardnervickers
gardnervickers / gist:9e915efc3ec875c68bcd
Last active August 29, 2015 14:21
flow-combine in onyx
Executing before task -=___ Peer 1 starts task/job and batch
Executing before batch -=__/ Segments are loaded through the :core.async/read-from-chan :in
Executing after batch -=__/
Executing before batch -=___ Segments are loaded into the :inc function and processed
Executing after batch -=__/
Executing before batch -=___ Segments are loaded through the :core.async/write-to-chan :out
Executing after task -=___ Why does this happen *before* "Executing after batch"
Executing after batch -=__/
(ns flat-workflow.functions.sample-functions)
(defn ^{:batch-size 10 :onyx? true} increment-age [segment]
(update-in segment [:age] inc))
(defn ^{:batch-size 10 :onyx? true} legal?
"hello world"
[age segment]
age)
(ns statefunction.web
(:require [compojure.core :refer [defroutes GET PUT POST DELETE ANY]]
[compojure.handler :refer [site]]
[compojure.route :as route]
[clojure.java.io :as io]
[ring.middleware.stacktrace :as trace]
[ring.middleware.session :as session]
[ring.middleware.session.cookie :as cookie]
[ring.adapter.jetty :as jetty]
[ring.middleware.basic-authentication :as basic]