Last active
September 26, 2015 19:55
-
-
Save bhagany/4df04455e203992108b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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