queueAvailableIds function

parent 0591a643
Pipeline #6884 passed with stages
in 6 minutes and 42 seconds
......@@ -33,7 +33,8 @@ module Database.PGMQ.Simple
, sendMessage
, sendMessages
, setMessageVt
, queueAvailableLength )
, queueAvailableLength
, queueAvailableIds )
where
......@@ -279,6 +280,14 @@ queueAvailableLength conn queue = do
[PSQL.Only len] <- PSQL.query conn [sql| SELECT COUNT(*) FROM ? WHERE vt <= now() |] (PSQL.Only tableId) :: IO [PSQL.Only Int]
return len
-- | Same as 'queryAvailableLength' but returns the ids of messages.
queueAvailableIds :: PSQL.Connection -> Queue -> IO [MessageId]
queueAvailableIds conn queue = do
let queueTable = "q_" <> queue
let tableId = PSQL.QualifiedIdentifier (Just "pgmq") $ T.pack queueTable
ret <- PSQL.query conn [sql| SELECT msg_id FROM ? WHERE vt <= now() |] (PSQL.Only tableId) :: IO [PSQL.Only MessageId]
return $ (\(PSQL.Only msgId) -> msgId) <$> ret
{-|
A utility function: sometimes pgmq throws an error that a table (for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment