úÎ7š5*      !"#$%&'()NonetThis function creates a table and enumeration type that is appriopiate for the queue. The following sql is used. CREATE TYPE state_t AS ENUM (enqueued, locked, dequeuedh); CREATE TABLE payloads ( id uuid PRIMARY KEY , value jsonb NOT NULL , state state_t NOT NULL DEFAULT enqueuedÿ$ , created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT clock_timestamp() , modified_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT clock_timestamp() ); CREATE INDEX state_idx ON payloads (state); CREATE OR REPLACE FUNCTION update_row_modified_function_() RETURNS TRIGGER AS $$ BEGIN -- ASSUMES the table has a column named exactly "modified_at". -- Fetch date-time of actual current moment from clock, -- rather than start of statement or start of transaction. NEW.modified_at = clock_timestamp(); RETURN NEW; END; $$ language plpgsql; None !":IT[ The JSON value of a payloadA ) can exist in three states in the queue,  ,   and  . A  starts in the   state and is  D so some sort of process can occur with it, usually something in **. Once the processing is complete, the  is moved the  ' state, which is the terminal state.ÙEnqueue a new JSON value into the queue. This particularly function can be composed as part of a larger database transaction. For instance, a single transaction could create a user and enqueue a email message. % createAccount userRecord = do +. $ do createUserDB userRecord $ $ makeVerificationEmail userRecord Return a the oldest  in the   state, or ,¸ if there are no payloads. This function is not necessarily useful by itself, since there are not many use cases where it needs to be combined with other transactions. See a the IO API version, or for a blocking version utilizing PostgreSQL's NOTIFY and LISTEN, see  Transition a  from the   state to the  ~ state. Useful for responding to asynchronous exceptions during a unexpected shutdown. In general the IO API version, K, is probably more useful. The DB version is provided for completeness. Transition a  to the   state.Get the number of rows in the   state.-Enqueue a new JSON value into the queue. See T for a version which can be composed with other queries in a single transaction.Return a the oldest  in the   state or ,h if there are no payloads. For a blocking version utilizing PostgreSQL's NOTIFY and LISTEN, see . This functions runs  as a - transaction.Return the oldest  in the  Þ state or block until a payload arrives. This function utilizes PostgreSQL's LISTEN and NOTIFY functionality to avoid excessively polling of the DB while waiting for new payloads, without scarficing promptness. Transition a  from the   state to the  x state. Useful for responding to asynchronous exceptions during a unexpected shutdown. For a DB API version see  Transition a  to the   state. his functions runs  as a - transaction.Get the number of rows in the   state. This function runs  in a . transaction.! /01     /012      !"#$%&'()*+,-./012345645789:;6postgresql-simple-queue-0.5.0.0-8Zg16cMIjhRDdFkGm0vduO(Database.PostgreSQL.Simple.Queue.Migrate Database.PostgreSQL.Simple.QueuemigratePayloadpIdpValuepState pCreatedAt pModifiedAtStateEnqueuedLockedDequeued PayloadId unPayloadId enqueueDB tryLockDBunlockDB dequeueDB getCountDBenqueuetryLocklockunlockdequeuegetCount$fFromRowPayload$fFromFieldState$fToFieldState$fToRowPayloadId$fFromRowPayloadId $fEqPayloadId$fShowPayloadId$fFromFieldPayloadId$fToFieldPayloadId $fShowState $fEqState $fOrdState $fEnumState$fBoundedState $fShowPayload $fEqPayloadghc-prim GHC.TypesIO*pg-transact-0.1.0.1-HaoSKcaqqHwLGJHdHFNrKaDatabase.PostgreSQL.TransactrunDBTSerializablebaseGHC.BaseNothing/postgresql-simple-0.5.3.0-506pMDhpFXUYO6OgD5Fqr&Database.PostgreSQL.Simple.Transaction Serializable ReadCommitted withSchema notifyName notifyPayload