on master help sign in
Upgrade data.pool to 0.4.0.0

set bound fix build errors add more stacks to build focribly set stack.yaml use a ci config that works consistent naming scheme bump verions, add note to chagnelog, fix lts 18 fix more missing deps add nightly put extra deps of 18 into 16 fix lts 16 add hdaemonize drop osx support add ancient pool support add hdaemonize downgrade servant add missing extra deps fix lts and nightly again use servant 20 servant lucid specify m fix 16 fix stack fix hlint drop lts-16 support this is just to old fix resource pool to a specific version this is getting to hard to maintain try run in io lift io more fix compile errors Revert "use a ci config that works" This reverts commit 4bfabd70f2b182cafb74f674e1453a3c9cc7bdee. undo my changes remove parens I guess there can only be one stack.yaml

commitcfb0aefb71e2417c47180a8d141293aeb94fade5 authorJappie Klooster <jappieklooster@hotmail.com> dateWed 28 Jun 2023, 14:09 (3 years ago) parent6048113
10 files changed+23−110
.github/workflows/ci.yml+2−2 CHANGELOG.md+3 ghc-8.10.7.stack.yaml−8 ghc-8.10.7.stack.yaml.lock−40 ghc-9.2.5.stack.yaml−5 ghc-9.2.5.stack.yaml.lock−19 odd-jobs.cabal+2−2 src/OddJobs/ConfigBuilder.hs+2−9 stack.yaml+2−1 test/Test.hs+12−24
.github/workflows/ci.yml+2−2
@@ -14,8 +14,8 @@ jobs:
1414 strategy:
1515 matrix:
1616 os: [ubuntu-latest]
17− stack: ["2.9.1"]
18− ghc: ["8.8.4", "8.10.7"]
17+ stack: ["2.11.1"]
18+ ghc: ["8.8.4", "8.10.7", "9.2.8", "9.4.5"]
1919
2020 services:
2121 postgres:
CHANGELOG.md+3
@@ -1,5 +1,8 @@
11# Changelog
22
3+## 0.2.3
4++ Upgrade resource pool
5+
36## 0.2.2
47
58- Bugfix in the `deleteJobQuery` function
ghc-8.10.7.stack.yamldeleted−8
@@ -1,8 +0,0 @@
1−resolver: lts-18.28
2−packages:
3− - .
4−extra-deps:
5− - daemons-0.3.0@sha256:356edaf06a8cf5e9f19685f9ce793ad6d2b6bce2e55379f6b2aff1b0c07a633f,3178
6− - servant-lucid-0.9.0.5@sha256:c46780eefc12544b862af1dd7c7f88715e5fb45d954da538b0641d42c7b5f5c6,1787
7− - servant-static-th-1.0.0.0@sha256:7dc46a426d8c78ee0386729159e8bbc18ff98e0dd700a2c723c87901b204fa6c,3883
8− - timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
ghc-8.10.7.stack.yaml.lockdeleted−40
@@ -1,40 +0,0 @@
1−# This file was autogenerated by Stack.
2−# You should not edit this file by hand.
3−# For more information, please see the documentation at:
4−# https://docs.haskellstack.org/en/stable/lock_files
5−
6−packages:
7−- completed:
8− hackage: daemons-0.3.0@sha256:356edaf06a8cf5e9f19685f9ce793ad6d2b6bce2e55379f6b2aff1b0c07a633f,3178
9− pantry-tree:
10− sha256: 26b1a5279be340c896edbc72baa6d95b071384b9bf7e19cd146025cf13d21769
11− size: 918
12− original:
13− hackage: daemons-0.3.0@sha256:356edaf06a8cf5e9f19685f9ce793ad6d2b6bce2e55379f6b2aff1b0c07a633f,3178
14−- completed:
15− hackage: servant-lucid-0.9.0.5@sha256:c46780eefc12544b862af1dd7c7f88715e5fb45d954da538b0641d42c7b5f5c6,1787
16− pantry-tree:
17− sha256: 7d529522482f4f83a62430a0fe245afc6272a5b9a63f2581388ac602654806c0
18− size: 392
19− original:
20− hackage: servant-lucid-0.9.0.5@sha256:c46780eefc12544b862af1dd7c7f88715e5fb45d954da538b0641d42c7b5f5c6,1787
21−- completed:
22− hackage: servant-static-th-1.0.0.0@sha256:7dc46a426d8c78ee0386729159e8bbc18ff98e0dd700a2c723c87901b204fa6c,3883
23− pantry-tree:
24− sha256: 13269fcc1c871ee1548d31010f0278484318bffbd9b8e0c0bfdfab4e27d6c3d5
25− size: 1493
26− original:
27− hackage: servant-static-th-1.0.0.0@sha256:7dc46a426d8c78ee0386729159e8bbc18ff98e0dd700a2c723c87901b204fa6c,3883
28−- completed:
29− hackage: timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
30− pantry-tree:
31− sha256: fbcb00f5b8a4f7b8fd94b034b7f507ffdd7579848de782ce60ad2b661dcb2b42
32− size: 469
33− original:
34− hackage: timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
35−snapshots:
36−- completed:
37− sha256: 428ec8d5ce932190d3cbe266b9eb3c175cd81e984babf876b64019e2cbe4ea68
38− size: 590100
39− url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/28.yaml
40− original: lts-18.28
ghc-9.2.5.stack.yamldeleted−5
@@ -1,5 +0,0 @@
1−resolver: lts-20.3
2−packages:
3− - .
4−extra-deps:
5− - timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
ghc-9.2.5.stack.yaml.lockdeleted−19
@@ -1,19 +0,0 @@
1−# This file was autogenerated by Stack.
2−# You should not edit this file by hand.
3−# For more information, please see the documentation at:
4−# https://docs.haskellstack.org/en/stable/lock_files
5−
6−packages:
7−- completed:
8− hackage: timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
9− pantry-tree:
10− sha256: fbcb00f5b8a4f7b8fd94b034b7f507ffdd7579848de782ce60ad2b661dcb2b42
11− size: 469
12− original:
13− hackage: timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
14−snapshots:
15−- completed:
16− sha256: 03cec7d96ed78877b03b5c2bc5e31015b47f69af2fe6a62d994a42b7a43c5805
17− size: 648659
18− url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/3.yaml
19− original: lts-20.3
odd-jobs.cabal+2−2
@@ -7,7 +7,7 @@ cabal-version: 1.12
77-- hash: dff1ced317b40e54688799203ec3743b119bf71f2fc98109a5e79f12c6e10fba
88
99name: odd-jobs
10−version: 0.2.2
10+version: 0.2.3
1111synopsis: A full-featured PostgreSQL-backed job queue (with an admin UI)
1212description: - Background jobs library for Haskell.
1313 - Extracted from production code at [Vacation Labs](https://www.vacationlabs.com).
@@ -89,7 +89,7 @@ library
8989 , mtl
9090 , optparse-applicative
9191 , postgresql-simple
92− , resource-pool
92+ , resource-pool >= 0.4.0.0 && < 0.5.0.0
9393 , safe
9494 , servant
9595 , servant-lucid
src/OddJobs/ConfigBuilder.hs+2−9
@@ -286,17 +286,10 @@ withConnectionPool connConfig action = withRunInIO $ \runInIO -> do
286286 where
287287 poolCreator = liftIO $
288288 case connConfig of
289−#if MIN_VERSION_resource_pool(0,3,0)
290289 Left connString ->
291− newPool $ PoolConfig (PGS.connectPostgreSQL connString) PGS.close (fromIntegral $ 2 * unSeconds defaultPollingInterval) 8
290+ newPool $ defaultPoolConfig (PGS.connectPostgreSQL connString) PGS.close (fromIntegral $ 2 * unSeconds defaultPollingInterval) 8
292291 Right connInfo ->
293− newPool $ PoolConfig (PGS.connect connInfo) PGS.close (fromIntegral $ 2 * unSeconds defaultPollingInterval) 8
294−#else
295− Left connString ->
296− createPool (PGS.connectPostgreSQL connString) PGS.close 1 (fromIntegral $ 2 * unSeconds defaultPollingInterval) 8
297− Right connInfo ->
298− createPool (PGS.connect connInfo) PGS.close 1 (fromIntegral $ 2 * unSeconds defaultPollingInterval) 8
299−#endif
292+ newPool $ defaultPoolConfig (PGS.connect connInfo) PGS.close (fromIntegral $ 2 * unSeconds defaultPollingInterval) 8
300293
301294-- | A convenience function to help you define a timed-logger with some sensible
302295-- defaults.
stack.yaml+2−1
@@ -1,5 +1,6 @@
1−resolver: lts-20.3
1+resolver: lts-20.26
22packages:
33 - .
44extra-deps:
55 - timing-convenience-0.1@sha256:7ff807a9a9e5596f2b18d45c5a01aefb91d4a98f6a1008d183b5c550f68f7cb7,2092
6+ - resource-pool-0.4.0.0@sha256:9c1e448a159875e21a7e68697feee2b61a4e584720974fa465a2fa1bc0776c73,1342
test/Test.hs+12−24
@@ -5,6 +5,7 @@
55{-# OPTIONS_GHC -Wno-missing-signatures -Wno-partial-type-signatures #-}
66module Test where
77
8+import Control.Monad.Trans.Control
89import Test.Tasty as Tasty
910import qualified OddJobs.Migrations as Migrations
1011import qualified OddJobs.Job as Job
@@ -36,7 +37,6 @@ import Test.Tasty.Hedgehog
3637import qualified System.Random as R
3738import Data.String (fromString)
3839import qualified Data.IntMap.Strict as Map
39−import Control.Monad.Trans.Control (liftWith, restoreT)
4040import Control.Monad.Morph (hoist)
4141import Data.List as DL
4242import OddJobs.Web as Web
@@ -64,31 +64,16 @@ main = do
6464 , connectDatabase = "jobs_test"
6565 }
6666
67−#if MIN_VERSION_resource_pool(0,3,0)
68− createAppPool = Pool.newPool $ Pool.PoolConfig
67+ createAppPool = Pool.newPool $ Pool.defaultPoolConfig
6968 (PGS.connect connInfo) -- create a new resource
7069 PGS.close -- destroy resource
7170 (fromRational 10) -- number of seconds unused resources are kept around
7271 45
73− createJobPool = Pool.newPool $ Pool.PoolConfig
72+ createJobPool = Pool.newPool $ Pool.defaultPoolConfig
7473 (PGS.connect connInfo) -- create a new resource
7574 PGS.close -- destroy resource
7675 (fromRational 10) -- number of seconds unused resources are kept around
7776 45
78−#else
79− createAppPool = Pool.createPool
80− (PGS.connect connInfo) -- create a new resource
81− PGS.close -- destroy resource
82− 1 -- stripes
83− (fromRational 10) -- number of seconds unused resources are kept around
84− 45
85− createJobPool = Pool.createPool
86− (PGS.connect connInfo) -- create a new resource
87− PGS.close -- destroy resource
88− 1 -- stripes
89− (fromRational 10) -- number of seconds unused resources are kept around
90− 45
91−#endif
9277
9378tests appPool jobPool = testGroup "All tests"
9479 [
@@ -241,14 +226,17 @@ ensureJobId conn tname jid = Job.findJobByIdIO conn tname jid >>= \case
241226 Nothing -> error $ "Not expecting job to be deleted. JobId=" <> show jid
242227 Just j -> pure j
243228
244−withRandomTable :: _ => Pool Connection -> (Job.TableName -> m a) -> m a
229+withRandomTable :: (MonadBaseControl
230+ IO m, MonadUnliftIO m) => Pool Connection -> (Job.TableName -> m a) -> m a
245231withRandomTable jobPool action = do
232+ runInIO <- askRunInIO
246233 (tname :: Job.TableName) <- liftIO (fromString . ("jobs_" <>) <$> replicateM 10 (R.randomRIO ('a', 'z')))
247234 finally
248− (Pool.withResource jobPool (\conn -> liftIO $ Migrations.createJobTable conn tname) >> action tname)
249− (Pool.withResource jobPool $ \conn -> liftIO $ void $ PGS.execute conn "drop table if exists ?" (Only tname))
235+ (liftIO $ Pool.withResource jobPool (\conn -> liftIO $ Migrations.createJobTable conn tname) >> runInIO (action tname))
236+ (liftIO $ Pool.withResource jobPool $ \conn -> liftIO $ void $ PGS.execute conn "drop table if exists ?" (Only tname))
250237
251−withRandomResourceTables :: _ => Int -> Pool Connection -> Job.TableName -> (Job.ResourceCfg -> m a) -> m a
238+withRandomResourceTables :: (MonadBaseControl
239+ IO m, MonadUnliftIO m) => Int -> Pool Connection -> Job.TableName -> (Job.ResourceCfg -> m a) -> m a
252240withRandomResourceTables defaultLimit jobPool tname action = do
253241 resCfgResourceTable <- liftIO $ fromString . ("resources_" <>) <$> replicateM 10 (R.randomRIO ('a', 'z'))
254242 resCfgUsageTable <- liftIO $ fromString . ("usage_" <>) <$> replicateM 10 (R.randomRIO ('a', 'z'))
@@ -260,9 +248,9 @@ withRandomResourceTables defaultLimit jobPool tname action = do
260248
261249 finally
262250 (do
263− Pool.withResource jobPool $ \conn -> liftIO $ Migrations.createResourceTables conn tname resCfg
251+ liftIO $ Pool.withResource jobPool $ \conn -> liftIO $ Migrations.createResourceTables conn tname resCfg
264252 action resCfg)
265− (Pool.withResource jobPool $ \conn -> liftIO $ void $ PGS.execute conn
253+ (liftIO $ Pool.withResource jobPool $ \conn -> liftIO $ void $ PGS.execute conn
266254 "drop function if exists ?; drop table if exists ?; drop table if exists ?"
267255 (resCfgCheckResourceFunction, resCfgUsageTable, resCfgResourceTable))
268256