Skip to content

Instantly share code, notes, and snippets.

@bhagany
Last active September 26, 2015 19:55
Show Gist options
  • Save bhagany/4df04455e203992108b9 to your computer and use it in GitHub Desktop.
Save bhagany/4df04455e203992108b9 to your computer and use it in GitHub Desktop.
(defrecord DatascriptS3Db [bucket key-name schema conn-ch]
component/Lifecycle
(start [this]
(let [s3-conn-ch (chan 1 (map (s3-obj->conn schema)))
conn-ch (chan)]
(pipe (u/get-obj-ch bucket key-name) s3-conn-ch)
(go-loop [conn nil]
(let [conn* (if conn
conn
(<! s3-conn-ch))]
(>! conn-ch conn*)
(recur conn*)))
(assoc this :conn-ch conn-ch)))
(stop [this]
(close! conn-ch)
(dissoc this :conn-ch)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment