hasql-queue-1.2.0.2: A PostgreSQL backed queue

Safe HaskellNone
LanguageHaskell2010

Hasql.Queue.Low.AtLeastOnce

Contents

Description

A high throughput Session based API for a PostgreSQL backed queue.

Synopsis

Documentation

enqueue Source #

Arguments

:: Text

Notification channel name. Any valid PostgreSQL identifier

-> Connection

Connection

-> Value a

Payload encoder

-> [a]

List of payloads to enqueue

-> IO () 

Enqueue a list of payloads.

withDequeue Source #

Arguments

:: Text

Notification channel name. Any valid PostgreSQL identifier

-> Connection

Connection

-> Value a

Payload decoder

-> Int

Retry count

-> Int

Element count

-> ([a] -> IO b)

Continuation

-> IO b 

Wait for the next payload and process it. If the continuation throws an exception the payloads are put back in the queue. IOError is caught and withDequeue will retry up to the retry count. If withDequeue fails after too many retries the final exception is rethrown. If individual payloads are are attempted more than the retry count they are set as "failed". See failures to receive the list of failed payloads.

If the queue is empty withDequeue will block until it recieves a notification from the PostgreSQL server.

Listing API

data PayloadId Source #

Internal payload id. Used by the public api as continuation token for pagination.

Instances
Eq PayloadId Source # 
Instance details

Defined in Hasql.Queue.Internal

Show PayloadId Source # 
Instance details

Defined in Hasql.Queue.Internal

failures Source #

Arguments

:: Connection 
-> Value a

Payload decoder

-> Maybe PayloadId

Starting position of payloads. Pass Nothing to start at the beginning

-> Int

Count

-> IO [(PayloadId, a)] 

Retrieve the payloads that have entered a failed state. See withDequeue for how that occurs. The function returns a list of values and an id. The id is used the starting place for the next batch of values. If Nothing is passed the list starts at the beginning.

delete :: Connection -> [PayloadId] -> IO () Source #

Permantently remove a failed payload.

Advanced API

withDequeueWith Source #

Arguments

:: Exception e 
=> WithNotifyHandlers

Event handlers for events that occur as withDequeWith loops

-> Text

Notification channel name. Any valid PostgreSQL identifier

-> Connection

Connection

-> Value a

Payload decoder

-> Int

Retry count

-> Int

Element count

-> ([a] -> IO b)

Continuation

-> IO b 

A more general configurable version of withDequeue. Unlike withDequeue one can specify the exception that causes a retry. Additionally event handlers can be specified to observe the internal behavior of the retry loop.

data WithNotifyHandlers Source #

To aid in observability and white box testing

Constructors

WithNotifyHandlers 

Fields