eventuo11y-batteries 0.1.0.1 → 0.2.0.0
raw patch · 4 files changed
+21/−24 lines, 4 filesdep −asyncdep −unliftio-coredep ~eventuo11yPVP ok
version bump matches the API change (PVP)
Dependencies removed: async, unliftio-core
Dependency ranges changed: eventuo11y
API changes (from Hackage documentation)
- Observe.Event.Crash: type ScheduleCrash m r = Maybe r -> m ()
- Observe.Event.Servant.Client: instance Control.Monad.Reader.Class.MonadReader (Observe.Event.Implementation.EventBackend Servant.Client.Internal.HttpClient.ClientM r Observe.Event.Servant.Client.RunRequest) (Observe.Event.Servant.Client.ClientM r)
+ Observe.Event.Crash: data ScheduleCrash m r
+ Observe.Event.Servant.Client: instance Control.Monad.Reader.Class.MonadReader (Observe.Event.Backend.EventBackend Servant.Client.Internal.HttpClient.ClientM r Observe.Event.Servant.Client.RunRequest) (Observe.Event.Servant.Client.ClientM r)
- Observe.Event.Crash: withScheduleCrash :: MonadUnliftIO m => EventBackend m r Crashing -> DoCrash m -> (ScheduleCrash m r -> m a) -> m a
+ Observe.Event.Crash: withScheduleCrash :: MonadMask m => EventBackend m r Crashing -> DoCrash m -> (ScheduleCrash m r -> m a) -> m a
Files
- CHANGELOG.md +4/−0
- eventuo11y-batteries.cabal +2/−4
- src/Observe/Event/Crash.hs +11/−20
- src/Observe/Event/Wai.hs +4/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for eventuo11y-batteries +## 0.2.0.0 -- 2022-10-03++- Update for eventuo11y-0.2.0.0 BackendModification DSL+ ## 0.1.0.1 -- 2022-09-30 Relax aeson lower bound
eventuo11y-batteries.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: eventuo11y-batteries-version: 0.1.0.1+version: 0.2.0.0 synopsis: Grab bag of eventuo11y-enriched functionality description: Miscellaneous helpers for instrumenting with [eventuo11y](https://hackage.haskell.org/package/eventuo11y) and 3rd-party packages.@@ -27,13 +27,12 @@ build-depends: , aeson ^>=2.0.2.0- , async ^>=2.2.4 , base >=4.14 && <4.17 , binary ^>=0.8 , bytestring >=0.10.12.0 && <0.12 , case-insensitive ^>=1.2.1.0 , containers ^>=0.6- , eventuo11y ^>=0.1.0.1+ , eventuo11y ^>=0.2 , exceptions ^>=0.10.4 , http-media ^>=0.8.0.0 , http-types ^>=0.12.3@@ -45,7 +44,6 @@ , servant-client-core ^>=0.19 , text ^>=1.2.5.0 , transformers-base ^>=0.4.6- , unliftio-core ^>=0.2.0.1 , wai ^>=3.2.3 , warp ^>=3.3.19
src/Observe/Event/Crash.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-}+{-# LANGUAGE RecordWildCards #-} -- | -- Description : Combine eventuo11y instrumentation with crash-only designs.@@ -27,37 +28,27 @@ ) where -import Control.Concurrent.Async-import Control.Concurrent.MVar-import Control.Monad-import Control.Monad.IO.Unlift+import Control.Monad.Catch import Data.Void import Observe.Event+import Observe.Event.BackendModification import Observe.Event.Render.JSON -- | Run an action with a 'ScheduleCrash' that can be called to crash the application. withScheduleCrash ::- (MonadUnliftIO m) =>+ (MonadMask m) => EventBackend m r Crashing -> -- | Actually perform the crash. DoCrash m -> (ScheduleCrash m r -> m a) -> m a-withScheduleCrash backend crash go = withRunInIO $ \runInIO -> do- scheduleCrashChan <- newEmptyMVar- let waitForCrash = do- cause <- takeMVar scheduleCrashChan- withEvent (hoistEventBackend runInIO backend) Crashing \ev ->- maybe- (pure ())- (addProximate ev)- cause- runInIO crash- withAsync waitForCrash \_ ->- runInIO $ go $ void . liftIO . tryPutMVar scheduleCrashChan+withScheduleCrash backend crash go =+ go $ ScheduleCrash \mods ->+ let backend' = modifyEventBackend mods backend+ in withEvent backend' Crashing $ const crash --- | Function to schedule an application crash, perhaps caused by a referenced 'Event'.-type ScheduleCrash m r = Maybe r -> m ()+-- | Function to schedule an application crash.+newtype ScheduleCrash m r = ScheduleCrash {schedule :: forall r'. EventBackendModifiers r r' -> m ()} -- | Function to actually initiate the crash. type DoCrash m = m ()@@ -68,7 +59,7 @@ (forall x. f x -> g x) -> ScheduleCrash f r -> ScheduleCrash g r-hoistScheduleCrash nt s = nt . s+hoistScheduleCrash nt (ScheduleCrash {..}) = ScheduleCrash $ nt . schedule -- | Event selector for 'withScheduleCrash'. data Crashing f where
src/Observe/Event/Wai.hs view
@@ -81,6 +81,10 @@ -- | A 'Network.Wai.Handler.Warp.setOnException' callback which creates an 'Event' rendering -- 'Exception's.+--+-- Ideally this would have a way to get a parent 'Event' from 'application'. Would be nice to+-- use 'vault', but there doesn't seem to be a way to get at the 'Request' that Warp will pass+-- here. onExceptionCallback :: EventBackend IO r OnException -> Maybe Request -> SomeException -> IO () onExceptionCallback backend req e = if defaultShouldDisplayException e