@@ -65,24 +65,24 @@ main = do
6565#if MIN_VERSION_resource_pool(0,3,0)
6666 createAppPool = Pool.newPool $ Pool.PoolConfig
6767 (PGS.connect connInfo) -- create a new resource
68− (PGS.close) -- destroy resource
68+ PGS.close -- destroy resource
6969 (fromRational 10) -- number of seconds unused resources are kept around
7070 45
7171 createJobPool = Pool.newPool $ Pool.PoolConfig
7272 (PGS.connect connInfo) -- create a new resource
73− (PGS.close) -- destroy resource
73+ PGS.close -- destroy resource
7474 (fromRational 10) -- number of seconds unused resources are kept around
7575 45
7676#else
7777 createAppPool = Pool.createPool
7878 (PGS.connect connInfo) -- create a new resource
79− (PGS.close) -- destroy resource
79+ PGS.close -- destroy resource
8080 1 -- stripes
8181 (fromRational 10) -- number of seconds unused resources are kept around
8282 45
8383 createJobPool = Pool.createPool
8484 (PGS.connect connInfo) -- create a new resource
85− (PGS.close) -- destroy resource
85+ PGS.close -- destroy resource
8686 1 -- stripes
8787 (fromRational 10) -- number of seconds unused resources are kept around
8888 45
@@ -139,15 +139,15 @@ testPayload :: Value
139139testPayload = toJSON (10 :: Int)
140140
141141jobRunner :: Job.Job -> IO ()
142−jobRunner Job{jobPayload, jobAttempts} = case (fromJSON jobPayload) of
142+jobRunner Job{jobPayload, jobAttempts} = case fromJSON jobPayload of
143143 Aeson.Error e -> error e
144144 Success (j :: JobPayload) ->
145145 let recur pload idx = case pload of
146− PayloadAlwaysFail delay -> (delaySeconds delay) >> (error $ "Forced error after " <> show delay <> " seconds")
146+ PayloadAlwaysFail delay -> delaySeconds delay >> (error $ "Forced error after " <> show delay <> " seconds")
147147 PayloadSucceed delay -> void $ delaySeconds delay
148148 PayloadFail delay innerpload -> if idx<jobAttempts
149149 then recur innerpload (idx + 1)
150− else (delaySeconds delay) >> (error $ "Forced error after " <> show delay <> " seconds. step=" <> show idx)
150+ else delaySeconds delay >> (error $ "Forced error after " <> show delay <> " seconds. step=" <> show idx)
151151 PayloadThrowStringException s -> throwString s
152152 PayloadThrowDivideByZero -> seq (1 `div` 0 :: Integer) (pure ())
153153 in recur j 0
@@ -176,7 +176,7 @@ logEventToJob le = case le of
176176 Job.LogWebUIRequest -> Nothing
177177 Job.LogText _ -> Nothing
178178
179−assertJobIdStatus :: (HasCallStack)
179+assertJobIdStatus :: HasCallStack
180180 => Connection
181181 -> Job.TableName
182182 -> IORef [Job.LogEvent]
@@ -190,13 +190,13 @@ assertJobIdStatus conn tname logRef msg st jid = do
190190 case st of
191191 Job.Success ->
192192 assertBool (msg <> ": Success event not found in job-logs for JobId=" <> show jid) $
193− (flip DL.any) logs $ \case
193+ flip DL.any logs $ \case
194194 Job.LogJobSuccess j _ -> jid == Job.jobId j
195195 _ -> False
196196
197197 Job.Queued ->
198198 assertBool (msg <> ": Not expecting to find a queued job in the the job-logs JobId=" <> show jid) $
199− not $ (flip DL.any) logs $ \case
199+ not $ flip DL.any logs $ \case
200200 Job.LogJobStart j -> jid == Job.jobId j
201201 Job.LogJobSuccess j _ -> jid == Job.jobId j
202202 Job.LogJobFailed j _ _ _ -> jid == Job.jobId j
@@ -207,19 +207,19 @@ assertJobIdStatus conn tname logRef msg st jid = do
207207
208208 Job.Failed ->
209209 assertBool (msg <> ": Failed event not found in job-logs for JobId=" <> show jid) $
210− (flip DL.any) logs $ \case
210+ flip DL.any logs $ \case
211211 Job.LogJobFailed j _ _ _ -> jid == Job.jobId j
212212 _ -> False
213213
214214 Job.Retry ->
215215 assertBool (msg <> ": Failed event not found in job-logs for JobId=" <> show jid) $
216− (flip DL.any) logs $ \case
216+ flip DL.any logs $ \case
217217 Job.LogJobFailed j _ _ _ -> jid == Job.jobId j
218218 _ -> False
219219
220220 Job.Locked ->
221221 assertBool (msg <> ": Start event should be present in the log for a locked job JobId=" <> show jid) $
222− (flip DL.any) logs $ \case
222+ flip DL.any logs $ \case
223223 Job.LogJobStart j -> jid == Job.jobId j
224224 _ -> False
225225
@@ -228,16 +228,16 @@ assertJobIdStatus conn tname logRef msg st jid = do
228228 Nothing -> assertFailure $ "Not expecting job to be deleted. JobId=" <> show jid
229229 Just (Job{jobStatus}) -> assertEqual msg st jobStatus
230230
231−ensureJobId :: (HasCallStack) => Connection -> Job.TableName -> JobId -> IO Job
231+ensureJobId :: HasCallStack => Connection -> Job.TableName -> JobId -> IO Job
232232ensureJobId conn tname jid = Job.findJobByIdIO conn tname jid >>= \case
233233 Nothing -> error $ "Not expecting job to be deleted. JobId=" <> show jid
234234 Just j -> pure j
235235
236236-- withRandomTable :: (MonadIO m) => Pool Connection -> (Job.TableName -> m a) -> m a
237237withRandomTable jobPool action = do
238− (tname :: Job.TableName) <- liftIO ((fromString . ("jobs_" <>)) <$> (replicateM 10 (R.randomRIO ('a', 'z'))))
238+ (tname :: Job.TableName) <- liftIO (fromString . ("jobs_" <>) <$> replicateM 10 (R.randomRIO ('a', 'z')))
239239 finally
240− ((Pool.withResource jobPool $ \conn -> (liftIO $ Migrations.createJobTable conn tname)) >> (action tname))
240+ ((Pool.withResource jobPool $ \conn -> liftIO $ Migrations.createJobTable conn tname) >> action tname)
241241 (Pool.withResource jobPool $ \conn -> liftIO $ void $ PGS.execute conn "drop table if exists ?" (Only tname))
242242
243243testMaxAttempts :: Int
@@ -253,7 +253,7 @@ withNamedJobMonitor tname jobPool cfgFn actualTest = do
253253 tcache <- newTimeCache simpleTimeFormat'
254254 withTimedFastLogger tcache LogNone $ \tlogger -> do
255255 let flogger logLevel logEvent = do
256− tlogger $ \t -> toLogStr t <> " | " <> (Job.defaultLogStr Job.defaultJobType logLevel logEvent)
256+ tlogger $ \t -> toLogStr t <> " | " <> Job.defaultLogStr Job.defaultJobType logLevel logEvent
257257 atomicModifyIORef' logRef (\logs -> (logEvent:logs, ()))
258258 cfg = Job.mkConfig flogger tname jobPool Job.UnlimitedConcurrentJobs jobRunner (\cfg' -> cfgFn $ cfg'{Job.cfgDefaultMaxAttempts=testMaxAttempts})
259259 withAsync (Job.startJobRunner cfg) (const $ actualTest logRef)
@@ -263,7 +263,7 @@ payloadGen = Gen.recursive Gen.choice nonRecursive recursive
263263 where
264264 nonRecursive = [ PayloadAlwaysFail <$> Gen.element [1, 2, 3]
265265 , PayloadSucceed <$> Gen.element [1, 2, 3]]
266− recursive = [ PayloadFail <$> (Gen.element [1, 2, 3]) <*> payloadGen ]
266+ recursive = [ PayloadFail <$> Gen.element [1, 2, 3] <*> payloadGen ]
267267
268268testJobCreation appPool jobPool = testCase "job creation" $ do
269269 withNewJobMonitor jobPool $ \tname logRef -> do
@@ -282,7 +282,7 @@ testEnsureShutdown appPool jobPool = testCase "ensure shutdown" $ do
282282 scheduleJob tname = withNamedJobMonitor tname jobPool Prelude.id $ \logRef -> do
283283 t <- getCurrentTime
284284 Pool.withResource appPool $ \conn -> do
285− Job{jobId} <- Job.scheduleJob conn tname (PayloadSucceed 0) (addUTCTime (fromIntegral (2 * (unSeconds Job.defaultPollingInterval))) t)
285+ Job{jobId} <- Job.scheduleJob conn tname (PayloadSucceed 0) (addUTCTime (fromIntegral (2 * unSeconds Job.defaultPollingInterval)) t)
286286 assertJobIdStatus conn tname logRef "Job is scheduled in future, should still be queueud" Job.Queued jobId
287287 pure (jobId, logRef)
288288
@@ -331,15 +331,15 @@ testJobScheduling appPool jobPool = testCase "job scheduling" $ do
331331 job@Job{jobId} <- Job.scheduleJob conn tname (PayloadSucceed 0) (addUTCTime (fromIntegral (3600 :: Integer)) t)
332332 delaySeconds $ Seconds 2
333333 assertJobIdStatus conn tname logRef "Job is scheduled in the future. It should NOT have been successful by now" Job.Queued jobId
334− _ <- Job.saveJobIO conn tname job{jobRunAt = (addUTCTime (fromIntegral (-1 :: Integer)) t)}
335− delaySeconds (Job.defaultPollingInterval + (Seconds 2))
334+ _ <- Job.saveJobIO conn tname job{jobRunAt = addUTCTime (fromIntegral (-1 :: Integer)) t}
335+ delaySeconds (Job.defaultPollingInterval + Seconds 2)
336336 assertJobIdStatus conn tname logRef "Job had a runAt date in the past. It should have been successful by now" Job.Success jobId
337337
338338testJobFailure appPool jobPool = testCase "job failure" $ do
339339 withNewJobMonitor jobPool $ \tname _logRef -> do
340340 Pool.withResource appPool $ \conn -> do
341341 Job{jobId} <- Job.createJob conn tname (PayloadAlwaysFail 0)
342− delaySeconds $ (calculateRetryDelay testMaxAttempts) + (Seconds 3)
342+ delaySeconds $ calculateRetryDelay testMaxAttempts + Seconds 3
343343 Job{jobAttempts, jobStatus} <- ensureJobId conn tname jobId
344344 assertEqual "Exepcting job to be in Failed status" Job.Failed jobStatus
345345 assertEqual ("Expecting job attempts to be 3. Found " <> show jobAttempts) 3 jobAttempts
@@ -531,7 +531,7 @@ timeGen t d = do
531531 pure $ Time.timeSince t (fromInteger i) u d
532532
533533anyTimeGen :: MonadGen m => UTCTime -> m UTCTime
534−anyTimeGen t = (Gen.element (enumFrom Time.Ago)) >>= (timeGen t)
534+anyTimeGen t = Gen.element (enumFrom Time.Ago) >>= timeGen t
535535
536536futureTimeGen :: MonadGen m => UTCTime -> m UTCTime
537537futureTimeGen t = timeGen t Time.FromThat
@@ -584,7 +584,7 @@ genFilter t = do
584584 Nothing -> Gen.maybe (anyTimeGen t)
585585 Just x -> Gen.maybe (futureTimeGen x)
586586 orderClause <- Gen.maybe ((,) <$> (Gen.element $ enumFrom Web.OrdCreatedAt) <*> (Gen.element $ enumFrom Web.Asc))
587− limitOffset <- Gen.maybe ((,) <$> (Gen.int (Range.constant 5 10)) <*> (Gen.int (Range.constant 0 30)))
587+ limitOffset <- Gen.maybe ((,) <$> Gen.int (Range.constant 5 10) <*> Gen.int (Range.constant 0 30))
588588 runAfter <- Gen.maybe (futureTimeGen t)
589589 pure Web.blankFilter
590590 { filterStatuses = statuses
@@ -602,21 +602,21 @@ filterJobs :: Filter -> [Job] -> [Job]
602602filterJobs Web.Filter{filterStatuses, filterCreatedAfter, filterCreatedBefore, filterUpdatedAfter, filterUpdatedBefore, filterOrder, filterPage, filterRunAfter} js =
603603 applyLimitOffset $
604604 applyOrdering (fromMaybe (Web.OrdUpdatedAt, Web.Desc) filterOrder) $
605− (flip DL.filter) js $ \j -> (filterByStatus j) &&
606− (filterByCreatedAfter j) &&
607− (filterByCreatedBefore j) &&
608− (filterByUpdatedAfter j) &&
609− (filterByUpdatedBefore j) &&
610− (filterByRunAfter j)
605+ flip DL.filter js $ \j -> filterByStatus j &&
606+ filterByCreatedAfter j &&
607+ filterByCreatedBefore j &&
608+ filterByUpdatedAfter j &&
609+ filterByUpdatedBefore j &&
610+ filterByRunAfter j
611611 where
612− applyLimitOffset = maybe Prelude.id (\(l, o) -> (Prelude.take l). (Prelude.drop o)) filterPage
612+ applyLimitOffset = maybe Prelude.id (\(l, o) -> Prelude.take l . Prelude.drop o) filterPage
613613
614614 applyOrdering (fld, dir) lst =
615615 let comparer = resultOrder $ case fld of
616− Web.OrdCreatedAt -> (comparing jobCreatedAt)
617− Web.OrdUpdatedAt -> (comparing jobUpdatedAt)
618− Web.OrdLockedAt -> (comparing jobLockedAt)
619− Web.OrdStatus -> (comparing jobStatus)
616+ Web.OrdCreatedAt -> comparing jobCreatedAt
617+ Web.OrdUpdatedAt -> comparing jobUpdatedAt
618+ Web.OrdLockedAt -> comparing jobLockedAt
619+ Web.OrdStatus -> comparing jobStatus
620620 Web.OrdJobType -> comparing Job.defaultJobType
621621 resultOrder fn x y = case fn x y of
622622 EQ -> compare (Down $ jobId x) (Down $ jobId y)