Skip to content

Instantly share code, notes, and snippets.

@ordnungswidrig
Created July 20, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ordnungswidrig/7c60f01bac01ad0f8ced to your computer and use it in GitHub Desktop.
Save ordnungswidrig/7c60f01bac01ad0f8ced to your computer and use it in GitHub Desktop.
Break if control-ch contains a value
(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