BSD-3-Clause licensed by Jonathan Fischoff
Maintained by [email protected]
This version can be pinned in stack with:hasql-queue-1.0.1.1@sha256:44168c7e38e01c856430f90739d4c41ac13855df66300fe095aa8fae7be3dd36,3364

Module documentation for 1.0.1.1

Travis CI Status

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
  enqueueNotification "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

In the example above we used the Session API for enqueuing and the IO for dequeuing.

The Session API is useful for composing larger transactions and the IO utilizes PostgreSQL notifications to avoid polling.

Installation

stack install hasql-queue

Changes

Changelog for hasql-queue

  • 1.0.1.1

    • Fixed cabal meta data and copyright
  • 1.0.1

    • First release!