mirror of
https://github.com/jfischoff/hasql-queue.git
synced 2024-10-05 19:58:32 +03:00
hasql postgres queue
benchmarks | ||
flamecharts | ||
hasql-queue-tmp-db | ||
s | ||
src/Hasql/Queue | ||
test | ||
.gitignore | ||
.travis.yml | ||
cabal.project | ||
CHANGELOG.md | ||
developer_notes.md | ||
hasql-queue.cabal | ||
LICENSE | ||
package.yaml | ||
README.md | ||
Setup.hs | ||
stack.yaml | ||
stack.yaml.lock | ||
Vagrantfile |
hasql-queue
This module utilizes PostgreSQL to implement a durable queue for efficently processing payloads.
Typically a producer would enqueue a new payload as part of larger database transaction
createAccount userRecord = transaction Serializable Write $ do
createUser userRecord
enqueue "queue_channel" emailEncoder [makeVerificationEmail userRecord]
In another thread or process the consumer would drain the queue.
-- Wait for a single new record and try to send the email 5 times for giving
-- up and marking the payload as failed.
forever $ withDequeue "queue_channel" conn emailDecoder 5 1 $
mapM_ sendEmail