-
-
Save terjesb/58d9da26aeca4fcb8b6378216355513c 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
(def payment-codes-per-block 4096) | |
(defn create-payment-code-feed | |
[db] | |
(let [payment-code-feed (chan 10)] | |
(go-loop [] | |
(let [block-id (allocate-block db) | |
block-start (* block-id payment-codes-per-block)] | |
(-> (onto-chan payment-code-feed | |
(->> | |
(range block-start (+ block-start payment-codes-per-block)) | |
(map sa/int->six-alpha)) | |
;; Don't close! | |
false) | |
;; park here until all of that block has been consumed. | |
<!)) | |
;; Loop forever. | |
(recur)) | |
payment-code-feed)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment