packages feed

snaplet-persistent 0.4 → 0.4.1

raw patch · 2 files changed

+27/−4 lines, 2 filesdep +resource-pooldep −resource-pool-catchio

Dependencies added: resource-pool

Dependencies removed: resource-pool-catchio

Files

snaplet-persistent.cabal view
@@ -1,5 +1,5 @@ name:           snaplet-persistent-version:        0.4+version:        0.4.1 synopsis:       persistent snaplet for the Snap Framework description:    Snaplet support for using the Postgresql database                 with a Snap Framework application via the persistent@@ -51,7 +51,7 @@     persistent-postgresql      >= 1.2     && < 1.4,     persistent-template        >= 1.2     && < 1.4,     readable                   >= 0.1     && < 0.3,-    resource-pool-catchio      >= 0.2     && < 0.3,+    resource-pool              >= 0.2     && < 0.3,     resourcet                  >= 0.4     && < 1.2,     safe                       >= 0.3     && < 0.4,     snap                       >= 0.13    && < 0.14,
src/Snap/Snaplet/Persistent.hs view
@@ -5,6 +5,7 @@  module Snap.Snaplet.Persistent   ( initPersist+  , initPersistGeneric   , PersistState(..)   , HasPersistPool(..)   , mkPgPool@@ -33,6 +34,7 @@ import           Data.Configurator import           Data.Configurator.Types import           Data.Maybe+import           Data.Pool import           Data.Readable import           Data.Text                    (Text) import qualified Data.Text                    as T@@ -80,8 +82,29 @@ -- by the QQ statement in your persistent schema definition in the -- call to 'mkMigrate'. initPersist :: SqlPersistT (NoLoggingT IO) a -> SnapletInit b PersistState-initPersist migration = makeSnaplet "persist" description datadir $ do-    p <- mkSnapletPgPool+initPersist = initPersistGeneric mkSnapletPgPool+++-------------------------------------------------------------------------------+-- | Backend-agnostic initalization with an initial SQL function called right+-- after the connection pool has been created. This is most useful for+-- calling migrations upfront right after initialization.+--+-- Example:+--+-- > initPersist mkPool (runMigrationUnsafe migrateAll)+--+-- where migrateAll is the migration function that was auto-generated+-- by the QQ statement in your persistent schema definition in the+-- call to 'mkMigrate'.+--+-- mkPool is a function to construct a pool of connections to your database+initPersistGeneric+    :: Initializer b PersistState (Pool Connection)+    -> SqlPersistT (NoLoggingT IO) a+    -> SnapletInit b PersistState+initPersistGeneric mkPool migration = makeSnaplet "persist" description datadir $ do+    p <- mkPool     liftIO . runNoLoggingT $ runSqlPool migration p     return $ PersistState p   where