on master help sign in
Use safe-exceptions instead of enclosed-exceptions

They're both attempting the same thing, to avoid catching async exceptions. safe-exceptions uses an exception hierarchy instead of forking threads which should have better performance.

commitf9ccb807b923c915838cbdb82d3e84828f0a4f49 authorMichael Xavier <michael@michaelxavier.net> dateWed 9 Jan 2019, 09:03 (8 years ago) parenta1a0d8e
2 files changed+10−11
katip-elasticsearch/katip-elasticsearch.cabal+1−1 katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+9−10
katip-elasticsearch/katip-elasticsearch.cabal+1−1
@@ -42,7 +42,7 @@ library
4242 , stm >= 2.4.3 && < 2.6
4343 , stm-chans >= 3.0.0.2 && < 3.1
4444 , async >= 2.0.1.0 && < 3.0
45− , enclosed-exceptions >= 1.0.0 && < 1.1
45+ , safe-exceptions >= 0.1.0.0
4646 , http-client >= 0.3 && < 0.6
4747 , text >= 0.11 && < 1.3
4848 , retry >= 0.7 && < 0.8
katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+9−10
@@ -16,8 +16,7 @@ import Control.Applicative as A
1616import Control.Concurrent
1717import Control.Concurrent.Async
1818import Control.Concurrent.STM.TBMQueue
19−import Control.Exception.Base
20−import Control.Exception.Enclosed
19+import qualified Control.Exception.Safe as EX
2120import Control.Monad
2221import Control.Monad.Catch
2322import Control.Monad.IO.Class
@@ -28,7 +27,7 @@ import Control.Retry (RetryPolicy,
2827 recovering)
2928import Data.Aeson
3029import Data.ByteString.Lazy (ByteString)
31−import Data.List.NonEmpty (NonEmpty(..))
30+import Data.List.NonEmpty (NonEmpty (..))
3231import Data.Monoid ((<>))
3332import Data.Text (Text)
3433import qualified Data.Text as T
@@ -282,21 +281,21 @@ mkEsScribe cfg@EsScribeCfg {..} env ix mapping permit verb = do
282281 -- create or update
283282 res <- putTemplate prx tpl tplName
284283 unless (statusIsSuccessful (responseStatus res)) $
285− liftIO $ throwIO (CouldNotPutTemplate res)
284+ liftIO $ EX.throwIO (CouldNotPutTemplate res)
286285 else do
287286 ixExists <- indexExists prx ix
288287 if ixExists
289288 then do
290289 res <- updateIndexSettings prx (toUpdatabaleIndexSettings prx essIndexSettings) ix
291290 unless (statusIsSuccessful (responseStatus res)) $
292− liftIO $ throwIO (CouldNotUpdateIndexSettings res)
291+ liftIO $ EX.throwIO (CouldNotUpdateIndexSettings res)
293292 else do
294293 r1 <- createIndex prx essIndexSettings ix
295294 unless (statusIsSuccessful (responseStatus r1)) $
296− liftIO $ throwIO (CouldNotCreateIndex r1)
295+ liftIO $ EX.throwIO (CouldNotCreateIndex r1)
297296 r2 <- putMapping prx ix mapping base
298297 unless (statusIsSuccessful (responseStatus r2)) $
299− liftIO $ throwIO (CouldNotCreateMapping r2)
298+ liftIO $ EX.throwIO (CouldNotCreateMapping r2)
300299
301300 workers <- replicateM (unEsPoolSize essPoolSize) $ async $
302301 startWorker cfg env mapping q
@@ -421,7 +420,7 @@ startWorker EsScribeCfg {..} env mapping q = go
421420 popped <- atomically $ readTBMQueue q
422421 case popped of
423422 Just (ixn, v) -> do
424− sendLog ixn v `catchAny` eat
423+ sendLog ixn v `EX.catchAny` eat
425424 go
426425 Nothing -> return ()
427426 prx :: Typeable.Proxy v
@@ -434,8 +433,8 @@ startWorker EsScribeCfg {..} env mapping q = go
434433 eat _ = return ()
435434 handler _ = Handler $ \e ->
436435 case fromException e of
437− Just (_ :: AsyncException) -> return False
438− _ -> return True
436+ Just (_ :: EX.SomeAsyncException) -> return False
437+ _ -> return True
439438
440439
441440-------------------------------------------------------------------------------