packages feed

postgresql-simple-queue 1.0.0 → 1.0.1

raw patch · 3 files changed

+54/−39 lines, 3 files

Files

postgresql-simple-queue.cabal view
@@ -1,9 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: 54ecbff1eaa2b7aadf2870516b4db0aeb56c9671f79120584006de5903dbff75  name:           postgresql-simple-queue-version:        1.0.0+version:        1.0.1 synopsis:       A PostgreSQL backed queue description:    This module utilize PostgreSQL to implement a durable queue for efficently processing arbitrary payloads which can be represented as JSON.                 .@@ -31,14 +33,14 @@                 >                 > To support multiple queues in the same database, the API expects a table name string                 > to determine which queue tables to use.+category:       Web homepage:       https://github.com/jfischoff/postgresql-queue#readme bug-reports:    https://github.com/jfischoff/postgresql-queue/issues-license:        BSD3-license-file:   LICENSE author:         Jonathan Fischoff maintainer:     jonathangfischoff@gmail.com copyright:      2017 Jonathan Fischoff-category:       Web+license:        BSD3+license-file:   LICENSE build-type:     Simple cabal-version:  >= 1.10 @@ -52,53 +54,54 @@ library   hs-source-dirs:       src+  ghc-options: -Wall -Wno-unused-do-bind+  build-depends:+      aeson+    , base >=4.7 && <5+    , bytestring+    , exceptions+    , monad-control+    , pg-transact+    , postgresql-simple+    , random+    , stm+    , text+    , time+    , transformers   exposed-modules:       Database.PostgreSQL.Simple.Queue       Database.PostgreSQL.Simple.Queue.Migrate   other-modules:       Paths_postgresql_simple_queue-  build-depends:-      base >=4.7 && <5-    , time-    , transformers-    , random-    , text-    , monad-control-    , exceptions-    , postgresql-simple-    , pg-transact-    , aeson-    , bytestring-    , stm   default-language: Haskell2010-  ghc-options: -Wall -Wno-unused-do-bind  test-suite unit-tests   type: exitcode-stdio-1.0+  main-is: Spec.hs   hs-source-dirs:       test-  main-is: Spec.hs-  other-modules:-      Database.PostgreSQL.Simple.QueueSpec+  ghc-options: -Wall -Wno-unused-do-bind -O2 -threaded -rtsopts -with-rtsopts=-N   build-depends:-      base >=4.7 && <5-    , time-    , transformers-    , random-    , text-    , monad-control-    , exceptions-    , postgresql-simple-    , pg-transact-    , aeson+      aeson+    , async+    , base >=4.7 && <5     , bytestring-    , stm-    , postgresql-simple-queue+    , exceptions     , hspec     , hspec-discover     , hspec-expectations-lifted     , hspec-pg-transact-    , async+    , monad-control+    , pg-transact+    , postgresql-simple+    , postgresql-simple-queue+    , random     , split-  ghc-options: -Wall -Wno-unused-do-bind -O2 -threaded -rtsopts -with-rtsopts=-N+    , stm+    , text+    , time+    , transformers+  other-modules:+      Database.PostgreSQL.Simple.QueueSpec+      Paths_postgresql_simple_queue   default-language: Haskell2010
src/Database/PostgreSQL/Simple/Queue/Migrate.hs view
@@ -43,7 +43,12 @@   "CREATE SCHEMA IF NOT EXISTS " <> fromString schemaName <> ";" <>   "SET search_path TO " <> fromString schemaName <> ";" <> [sql| -  CREATE TYPE state_t AS ENUM ('enqueued', 'dequeued');+  DO $$+  BEGIN+    IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'state_t') THEN+      CREATE TYPE state_t AS ENUM ('enqueued', 'dequeued');+    END IF;+  END$$;    CREATE OR REPLACE FUNCTION update_row_modified_function()   RETURNS TRIGGER AS@@ -55,7 +60,7 @@   $$   language 'plpgsql'; -  CREATE TABLE payloads+  CREATE TABLE IF NOT EXISTS payloads   ( id BIGSERIAL PRIMARY KEY   , value jsonb NOT NULL   , attempts int NOT NULL DEFAULT 0@@ -64,9 +69,10 @@   , modified_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT clock_timestamp()   ); -  CREATE INDEX active_created_at_idx ON payloads (created_at)+  CREATE INDEX IF NOT EXISTS active_created_at_idx ON payloads (created_at)     WHERE (state = 'enqueued'); +  DROP TRIGGER IF EXISTS payloads_modified ON payloads;   CREATE TRIGGER payloads_modified   BEFORE UPDATE ON payloads   FOR EACH ROW EXECUTE PROCEDURE update_row_modified_function();
test/Database/PostgreSQL/Simple/QueueSpec.hs view
@@ -10,6 +10,7 @@ import           Data.List import           Database.PostgreSQL.Simple.Queue import           Database.PostgreSQL.Simple.Queue.Migrate+import           Database.PostgreSQL.Transact (getConnection) import           Test.Hspec                     (Spec, hspec, it) import           Test.Hspec.Expectations.Lifted import           Test.Hspec.DB@@ -27,6 +28,11 @@  spec :: Spec spec = describeDB (migrate schemaName) "Database.Queue" $ do++  it "is okay to migrate multiple times" $ \db -> runDB db $ do+      conn <- getConnection+      replicateM_ 2 $ liftIO $ migrate schemaName conn+   itDB "empty locks nothing" $     (either throwM return =<< (withPayloadDB schemaName 8 return))       `shouldReturn` Nothing