Created
July 20, 2015 09:59
-
-
Save ordnungswidrig/7c60f01bac01ad0f8ced to your computer and use it in GitHub Desktop.
Break if control-ch contains a value
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
(def capacity 100) | |
(let [conn (d/connect db-uri) | |
tx-report-ch (chan 100) | |
control-ch (chan)] | |
(thread | |
(log/info "Started tx-report thread for " db-uri) | |
(try (let [queue (d/tx-report-queue conn)] | |
(while (= ::continue (alts! [control-ch] ::continue)) | |
(when-let [tx-result (.take queue)] | |
(doseq [datom (:tx-data tx-result) | |
:let [datom {:datom (tuplise datom) | |
:db-uri db-uri | |
:t (t-for-db db-uri)}]] | |
(log/info "Reporting tx datom:" datom) | |
(>!! tx-report-ch datom))))) | |
(catch Exception e | |
(log/debug "TX-REPORT-TAKE exception: " e) | |
(throw e)))) | |
{:core.async/chan tx-report-ch | |
:control-chan control-ch}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment