Switch to pool-conduit · unclechu/persistent@349c058 · GitHub
Skip to content

Commit 349c058

Browse files
committed
Switch to pool-conduit
1 parent 7010e7c commit 349c058

16 files changed

Lines changed: 106 additions & 225 deletions

File tree

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions

‎package-list.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
pkgs=( ./pool
4+
./pool-conduit
45
./persistent
56
./persistent-template
67
./persistent-sqlite

‎persistent-test/persistent-test.cabal‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ library
6363
, random == 1.*
6464
, QuickCheck == 2.4.*
6565
, blaze-html
66-
, pool
66+
, pool-conduit
6767
, transformers-base
6868

6969
-- postgresql dependencies

‎persistent/Database/Persist/GenericSql.hs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import Control.Arrow ((&&&))
4646
import Database.Persist.Store
4747
import Control.Monad.IO.Class
4848
import Control.Monad.Trans.Reader
49-
import Data.Pool
49+
import Data.Conduit.Pool
5050
import Database.Persist.GenericSql.Internal
5151
import Database.Persist.GenericSql.Migration
5252
import qualified Database.Persist.GenericSql.Raw as R
@@ -84,8 +84,8 @@ instance PathPiece (Key SqlPersist entity) where
8484
execute' :: MonadIO m => Text -> [PersistValue] -> SqlPersist m ()
8585
execute' = R.execute
8686

87-
runSqlPool :: (MBCIO m, MonadIO m) => SqlPersist m a -> Pool Connection -> m a
88-
runSqlPool r pconn = withPool' pconn $ runSqlConn r
87+
runSqlPool :: C.ResourceIO m => SqlPersist m a -> Pool Connection -> m a
88+
runSqlPool r pconn = withResource pconn $ runSqlConn r
8989

9090
runSqlConn :: (MBCIO m, MonadIO m) => SqlPersist m a -> Connection -> m a
9191
runSqlConn (SqlPersist r) conn = do

‎persistent/Database/Persist/GenericSql/Internal.hs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Prelude hiding ((++))
2020
import qualified Data.Map as Map
2121
import Data.IORef
2222
import Control.Monad.IO.Class
23-
import Data.Pool
23+
import Data.Conduit.Pool
2424
import Database.Persist.Store
2525
import Database.Persist.Query
2626
import Control.Exception.Lifted (bracket)
@@ -58,8 +58,13 @@ data Statement = Statement
5858
}
5959

6060
withSqlPool :: C.ResourceIO m
61-
=> IO Connection -> Int -> (Pool Connection -> m a) -> m a
62-
withSqlPool mkConn = createPool mkConn close'
61+
=> IO Connection -- ^ create a new connection
62+
-> Int -- ^ connection count
63+
-> (Pool Connection -> m a)
64+
-> m a
65+
withSqlPool mkConn connCount f = do
66+
pool <- liftIO $ createPool mkConn close' 1 20 connCount
67+
f pool
6368

6469
withSqlConn :: C.ResourceIO m
6570
=> IO Connection -> (Connection -> m a) -> m a

‎persistent/Database/Persist/Store.hs‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,8 @@ import qualified Data.Text.Encoding as T
7272
import qualified Data.Text.Encoding.Error as T
7373
import Web.PathPieces (PathPiece (..))
7474
import qualified Data.Text.Read
75-
import Control.Monad.IO.Class (MonadIO)
7675
import qualified Data.Conduit as C
7776

78-
#if MIN_VERSION_monad_control(0, 3, 0)
79-
import Control.Monad.Trans.Control (MonadBaseControl)
80-
#define MBCIO MonadBaseControl IO
81-
#else
82-
import Control.Monad.IO.Control (MonadControlIO)
83-
#define MBCIO MonadControlIO
84-
#endif
8577
import Data.Aeson (Value)
8678
import Data.Aeson.Types (Parser)
8779

@@ -557,7 +549,7 @@ class PersistConfig c where
557549
loadConfig :: Value -> Parser c
558550
-- | I really don't want Applicative here, but it's necessary for Mongo.
559551
withPool :: (Applicative m, C.ResourceIO m) => c -> (PersistConfigPool c -> m a) -> m a
560-
runPool :: (MBCIO m, MonadIO m) => c -> PersistConfigBackend c m a
552+
runPool :: C.ResourceIO m => c -> PersistConfigBackend c m a
561553
-> PersistConfigPool c
562554
-> m a
563555

‎persistent/persistent.cabal‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ library
2929
, conduit >= 0.0 && < 0.1
3030
, monad-control >= 0.3 && < 0.4
3131
, lifted-base >= 0.1 && < 0.2
32-
, pool >= 0.1 && < 0.2
32+
, pool-conduit >= 0.0 && < 0.1
3333
, blaze-html >= 0.4 && < 0.5
3434
, path-pieces >= 0.1 && < 0.2
3535
, mtl >= 2.0 && < 2.1

‎pool‎

Submodule pool added at ebf08e3

‎pool-conduit/Data/Conduit/Pool.hs‎

Lines changed: 59 additions & 0 deletions
File renamed without changes.

0 commit comments

Comments
 (0)