on master help sign in
Add support for resource-pool 3

set lower bound to it as well. It's /much/ better. It's faster and async exception safe. Furthermore it has better logging capabilities. lax lower bound add mtl based withResource Use custom mtl withResource

commit79f2c9f902e52efc518420f44cd4a80e84828fbe authorJappie Klooster <jappieklooster@hotmail.com> dateSat 4 Jun 2022, 22:01 (4 years ago) parent154855b
2 files changed+7−2
odd-jobs.cabal+1−1 src/OddJobs/Job.hs+6−1
odd-jobs.cabal+1−1
@@ -81,7 +81,7 @@ library
8181 , mtl
8282 , optparse-applicative
8383 , postgresql-simple
84− , resource-pool
84+ , resource-pool >= 0.2.0.0 && < 0.4.0.0
8585 , safe
8686 , servant
8787 , servant-lucid
src/OddJobs/Job.hs+6−1
@@ -75,7 +75,8 @@ module OddJobs.Job
7575where
7676
7777import OddJobs.Types
78−import Data.Pool
78+import qualified Data.Pool as Pool
79+import Data.Pool(Pool)
7980import Data.Text as T
8081import Database.PostgreSQL.Simple as PGS
8182import Database.PostgreSQL.Simple.Notification
@@ -256,6 +257,10 @@ concatJobDbColumns = concatJobDbColumns_ jobDbColumns ""
256257findJobByIdQuery :: PGS.Query
257258findJobByIdQuery = "SELECT " <> concatJobDbColumns <> " FROM ? WHERE id = ?"
258259
260+withResource :: MonadUnliftIO m => Pool a -> (a -> m b) -> m b
261+withResource pool fa =
262+ withRunInIO $ \runInIO -> Pool.withResource pool (runInIO . fa)
263+
259264withDbConnection :: (HasJobRunner m)
260265 => (Connection -> m a)
261266 -> m a