@@ -1,5 +1,6 @@
1−{-# LANGUAGE DeriveDataTypeable #-}
2−{-# LANGUAGE RecordWildCards #-}
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE RecordWildCards #-}
3+{-# LANGUAGE ScopedTypeVariables #-}
34module Katip.Scribes.ElasticSearch
45 (-- * Building a scribe
56 mkEsScribe
@@ -22,10 +23,12 @@ module Katip.Scribes.ElasticSearch
2223-------------------------------------------------------------------------------
2324import Control.Concurrent
2425import Control.Concurrent.Async
25−import Control.Monad.STM
2626import Control.Concurrent.STM.TBMQueue
27+import Control.Exception.Base
2728import Control.Exception.Enclosed
2829import Control.Monad
30+import Control.Monad.Catch
31+import Control.Monad.STM
2932import Control.Retry
3033import Data.Aeson
3134import qualified Data.Text.Encoding as T
@@ -159,7 +162,11 @@ startWorker EsScribeCfg {..} env ix mapping q = forever $ do
159162 v <- atomically $ readTBMQueue q
160163 sendLog v `catchAny` eat
161164 where
162− sendLog v = void $ recoverAll essRetryPolicy $ do
165+ sendLog v = void $ recovering essRetryPolicy [handler] $ do
163166 did <- mkDocId
164167 runBH env $ indexDocument ix mapping v did
165168 eat _ = return ()
169+ handler _ = Handler $ \e ->
170+ case fromException e of
171+ Just (_ :: AsyncException) -> return False
172+ _ -> return True