This module utilize PostgreSQL to implement a durable queue for efficently processing arbitrary payloads which can be represented as JSON.
Typically a producer would enqueue a new payload as part of larger databasetransaction
createAccount userRecord = do 'runDBTSerializable' $ do createUserDB userRecord 'enqueueDB' "queue_schema" $ makeVerificationEmail userRecord
In another thread or process, the consumer would drain the queue.
forever $ do -- Attempt get a payload or block until one is available payload <- lock "queue" conn -- Perform application specifc parsing of the payload value case fromJSON $ pValue payload of Success x -> sendEmail x -- Perform application specific processing Error err -> logErr err -- Remove the payload from future processing dequeue "queue" conn $ pId payloadTo support multiple queues in the same database, the API expects a table name stringto determine which queue tables to use.
For package maintainers and hackage trustees
Candidates
| Versions[RSS] | 0.1.0.0,0.1.0.1,0.2.0.0,0.2.1.0,0.3.0.0,0.4.0.0,0.5.0.0,0.5.0.1,0.5.1.0,0.5.1.1,1.0.0,1.0.1 |
|---|---|
| Dependencies | aeson,base (>=4.7 && <5),bytestring,exceptions,monad-control,pg-transact,postgresql-simple,random,stm,text,time,transformers [details] |
| License | BSD-3-Clause |
| Copyright | 2017 Jonathan Fischoff |
| Author | Jonathan Fischoff |
| Maintainer | jonathangfischoff@gmail.com |
| Category | Web |
| Home page | https://github.com/jfischoff/postgresql-queue#readme |
| Bug tracker | https://github.com/jfischoff/postgresql-queue/issues |
| Source repo | head: git clonehttps://github.com/jfischoff/postgresql-queue |
| Uploaded | byJonathanFischoff at2017-12-21T03:26:39Z |
| Distributions | |
| Reverse Dependencies | 1 direct, 0 indirect [details] |
| Downloads | 7582 total (11 in the last 30 days) |
| Rating | (no votes yet)[estimated byBayesian average] |
| Your Rating |
|
| Status | Docs available[build log] Last success reported on 2017-12-21[all 1 reports] |
This module utilizes PostgreSQL to implement a durable queue for efficently processing arbitrary payloads which can be represented as JSON.
Typically a producer would enqueue a new payload as part of larger database transaction
createAccount userRecord = do runDBTSerializable $ do createUserDB userRecord enqueueDB $ makeVerificationEmail userRecordIn another thread or process, the consumer would drain the queue.
forever $ do -- Attempt get a payload or block until one is available payload <- lock conn -- Perform application specifc parsing of the payload value case fromJSON $ pValue payload of Success x -> sendEmail x -- Perform application specific processing Error err -> logErr err -- Remove the payload from future processing dequeue conn $ pId payloadstack install postgresql-simple-queueThis package was discussed in the blogTesting PostgreSQL for Fun