1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Remove some duplicate code

This commit is contained in:
Timothy Clem 2018-06-06 15:16:01 -07:00
parent 985ac4ade9
commit 170cadfcbd

View File

@ -136,25 +136,14 @@ runTaskWithOptions options task = do
statter <- defaultStatsClient >>= newQueue sendStat
logger <- newQueue logMessage options
(result, stat) <- withTiming "run" [] $ do
let run :: TaskEff a -> IO (Either SomeException a)
run = runM . runError
. runTelemetry logger statter
. runTraceInTelemetry
. runReader options
. IO.runFiles
. runResolution
. runTaskF
. runDistribute (run . unwrapTask)
run task
queue statter stat
result <- runTaskWithOptions' options logger statter task
closeQueue statter
closeStatClient (asyncQueueExtra statter)
closeQueue logger
either (die . displayException) pure result
runTaskWithOptions' :: Options -> AsyncQueue Message Options -> AsyncQueue Stat StatsClient -> TaskEff a -> IO a
runTaskWithOptions' :: Options -> AsyncQueue Message Options -> AsyncQueue Stat StatsClient -> TaskEff a -> IO (Either SomeException a)
runTaskWithOptions' options logger statter task = do
(result, stat) <- withTiming "run" [] $ do
let run :: TaskEff a -> IO (Either SomeException a)
@ -168,8 +157,7 @@ runTaskWithOptions' options logger statter task = do
. runDistribute (run . unwrapTask)
run task
queue statter stat
either (die . displayException) pure result
pure result
runTraceInTelemetry :: Member Telemetry effects => Eff (Trace ': effects) a -> Eff effects a
runTraceInTelemetry = interpret (\ (Trace str) -> writeLog Debug str [])