The postgresql-simple-queue package

[Tags:bsd3, library, program, test]

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 database transaction

  createAccount userRecord = do
     'runDBTSerializable' $ do
        createUserDB userRecord
        'enqueueDB' $ 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 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 payload

[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1
Dependencies aeson, amazonka, amazonka-ses, base (>=4.7 && <5), bytestring, data-default, exceptions, lens, lifted-async, lifted-base, monad-control, optparse-generic (>=1.2.1), pg-transact, postgresql-simple, postgresql-simple-opts, postgresql-simple-queue, random, resource-pool, text, time, transformers, uuid [details]
License BSD3
Copyright 2017 Jonathan Fischoff
Author Jonathan Fischoff
Maintainer jonathangfischoff@gmail.com
Category Web
Home page https://github.com/jfischoff/postgresql-queue#readme
Source repository head: git clone https://github.com/jfischoff/postgresql-queue
Uploaded Mon Jun 19 17:54:02 UTC 2017 by JonathanFischoff
Distributions NixOS:0.1.0.1, Stackage:0.1.0.1
Downloads 73 total (14 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2017-06-19 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for postgresql-simple-queue

Readme for postgresql-simple-queue-0.1.0.1

postgresql-simple-queue

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 database transaction

createAccount userRecord = do
  runDBTSerializable $ do
    createUserDB userRecord
    enqueueDB $ 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 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 payload

Installation

stack install postgresql-simple-queue

Blog

This package was discussed in the blog Testing PostgreSQL for Fun